location_postcodes does geometry lookups on centroid

This commit is contained in:
Sarah Hoffmann
2026-02-22 13:16:19 +01:00
parent 3e35d7fe26
commit f0d32501e4
2 changed files with 3 additions and 2 deletions

View File

@@ -153,8 +153,7 @@ BEGIN
IF ST_GeometryType(geom) in ('ST_Polygon','ST_MultiPolygon') THEN
SELECT min(postcode), count(*) FROM
(SELECT postcode FROM location_postcodes
WHERE geom && location_postcodes.geometry -- want to use the index
AND ST_Contains(geom, location_postcodes.centroid)
WHERE ST_Contains(geom, location_postcodes.centroid)
AND country_code = country
LIMIT 2) sub
INTO outcode, cnt;