#27448: GIS distance queries use deprecated ST_distance_sphere
-------------------------------------+-------------------------------------
Reporter: Christian | Owner: nobody
von Roques |
Type: Bug | Status: new
Component: GIS | Version: master
Severity: Normal | Keywords: GIS distance
Triage Stage: | deprecated ST_distance_sphere
Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When using `django.contrib.gis` with PostGIS 2.3.0, distance queries will
create SQL using the `ST_distance_sphere` function, which is deprecated
since PostGIS 2.2.0 (see http://trac.osgeo.org/postgis/ticket/2748 ). The
old function still works, but now issues a deprecation-warning. The
problem is that `ST_distance_sphere` has become more than 40× slower than
its replacement `ST_DistanceSphere` due to the added deprecation warning.
My `city_cities` table has 143260 rows. The following query executes in
about 7.5 seconds:
{{{#!sql
SELECT min(ST_distance_sphere(ST_Point(0,0), location)) FROM cities_city;
}}}
Whereas the same query with `ST_DistanceSphere` instead of
`ST_distance_sphere` completes in less than 170ms.
I've prepared a patch to stop Django from using the deprecated functions.
https://github.com/roques/django/tree/postgis22_deprecated The problem
with this patch is that the non-deprecated functions only became available
with PostGIS 2.2.0 and thus the patch would raise the minimum required
PostGIS version from 2.1.0.
As I can see the situation, we have a choice between the following three
scenarios:
1. Raise the required version of PostGIS from 2.1.0 to 2.2.0 and use the
non-deprecated functions.
2. Keep using the deprecated functions and live with all distance queries
being often unusably slow.
3. Complicate the code to detect the PostGIS version and use
`ST_DistanceSphere` when available or `ST_distance_sphere` otherwise.
I would prefer option 1, but people stuck with PostGIS <2.2.0 would then
be unable to make distance queries with newer releases of Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/27448>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.abd689e7aa3990933bf93c78e7a292a6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.