PostGIS 3.5.2 ST_Contains() query on gist is slow
Sebastiaan Couwenberg
sebastic at xs4all.nl
Mon Sep 8 21:27:22 PDT 2025
On 9/9/25 6:04 AM, Regina Obe wrote:
> To take GEOS out of the equation, what is performance if you just do below compared to your old performance
That is significantly faster:
osm-nl=# EXPLAIN (ANALYZE, BUFFERS) SELECT wn.way_id FROM way_nodes
AS wn, nodes AS n WHERE wn.node_id = 8646506472 AND wn.node_id = n.id
AND ST_GeomFromEWKT('SRID=4326;POLYGON((6.1198199
52.612195500000006,6.1198199 53.2038323,7.0927397
53.2038323,7.0927397 52.612195500000006,6.1198199
52.612195500000006))') @ n.geom;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nested Loop (cost=0.99..17.04 rows=1 width=8) (actual time=0.066..0.066 rows=0 loops=1)
Buffers: shared hit=9
-> Index Scan using idx_way_nodes_node_id on way_nodes wn (cost=0.57..8.59 rows=1 width=16) (actual time=0.024..0.025 rows=1 loops=1)
Index Cond: (node_id = '8646506472'::bigint)
Buffers: shared hit=5
-> Index Scan using idx_nodes_geom on nodes n (cost=0.42..8.44 rows=1 width=8) (actual time=0.040..0.040 rows=0 loops=1)
Index Cond: (geom ~ '0103000020E61000000100000005000000D5A35F11B27A184013A1116C5C4E4A40D5A35F11B27A18402A2F432D179A4A40D529EA27F75E1C402A2F432D179A4A40D529EA27F75E1C4013A1116C5C4E4A40D5A35F11B27A184013A1116C5C4E4A40'::geometry)
Filter: (id = '8646506472'::bigint)
Buffers: shared hit=4
Planning Time: 0.174 ms
Execution Time: 0.087 ms
(11 rows)
Kind Regards,
Bas
--
GPG Key ID: 4096R/6750F10AE88D4AF1
Fingerprint: 8182 DE41 7056 408D 6146 50D1 6750 F10A E88D 4AF1
More information about the postgis-users
mailing list