-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The nearest postcode lookup performance reduced dramatically when tried with Postgres 9.6 and PostGIS 2.3. This commit updates the query to use the ‘<->’ centroid distance operator instead, which makes better use of the geoindex and is much faster to execute. We fetch a few rows ordered by this, then sort by the actual distance, as the operator is returning 'degree' distances because postcodes are currently geometry objects. Handily, the work @dracos did to introduce the TrigramDistance function into Django 1.10 was easily adaptable for this purpose, as the operator used is the same.
- Loading branch information
Showing
2 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters