#28738: Addition of PostGIS <-> operator ------------------------------------+-------------------------------------- Reporter: Matthew Somerville | Owner: nobody Type: New feature | Status: new Component: GIS | Version: 1.11 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ------------------------------------+-------------------------------------- Description changed by Matthew Somerville:
Old description: > https://postgis.net/docs/geometry_distance_knn.html – this function is so > much quicker when looking up the nearest neighbour of an index, and it'd > be great to be built into Django. For example, on a dataset of c. 1.8 > million rows: > {{{ > postcode = Postcode.objects > .filter(location__distance_gte=(location, D(mi=0))) > .distance(location) > .order_by('distance')[0] > }}} > took 5 seconds, whereas: > {{{ > postcode = Postcode.objects > .annotate(centroid_distance=GeometryCentroidDistance('location', > location)) > .filter(centroid_distance__gte=0) > .distance(location) > .order_by('centroid_distance')[0] > }}} > is pretty instantaneous. > > (Where GeometryCentroidDistance is a Func subclass that sets` > function=''`, `arg_joiner = '<-> '`, output_field FloatField.) New description: https://postgis.net/docs/geometry_distance_knn.html – this function is so much quicker when looking up the nearest neighbour of an index, and it'd be great to be built into Django. For example, on a dataset of c. 1.8 million rows: {{{ postcode = Postcode.objects .filter(location__distance_gte=(location, D(mi=0))) .distance(location) .order_by('distance')[0] }}} took 5 seconds, whereas: {{{ postcode = Postcode.objects .annotate(centroid_distance=GeometryCentroidDistance('location', location)) .filter(centroid_distance__gte=0) .distance(location) .order_by('centroid_distance')[0] }}} is pretty instantaneous. (Where GeometryCentroidDistance is a Func subclass that sets` function=''`, `arg_joiner = '<-> '`, output_field FloatField.) (There is also `<#>` https://postgis.net/docs/geometry_distance_box.html) -- -- Ticket URL: <https://code.djangoproject.com/ticket/28738#comment:1> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.774d51229054e6f5e53464f47f3683b6%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.