Skip to content

Instantly share code, notes, and snippets.

@phyxolog
Created September 7, 2017 09:44
Show Gist options
  • Save phyxolog/5e2132f67133204de067680d97e0e5d3 to your computer and use it in GitHub Desktop.
Save phyxolog/5e2132f67133204de067680d97e0e5d3 to your computer and use it in GitHub Desktop.
# first query
Result (cost=532854.64..532854.65 rows=1 width=32) (actual time=497.493..497.493 rows=1 loops=1)
Buffers: shared hit=121273 read=174
InitPlan 3 (returns $2)
-> Seq Scan on placex place (cost=16.89..532854.64 rows=2778 width=185) (actual time=69.721..497.462 rows=25 loops=1)
Filter: (((name -> 'name'::text) = $1) AND st_dwithin(geometry, $0, '300'::double precision))
Rows Removed by Filter: 1666525
Buffers: shared hit=121273 read=174
InitPlan 1 (returns $0)
-> Index Scan using idx_place_id on placex (cost=0.43..8.45 rows=1 width=185) (actual time=0.008..0.008 rows=1 loops=1)
Index Cond: (place_id = 412369)
Buffers: shared hit=4
InitPlan 2 (returns $1)
-> Index Scan using idx_place_id on placex placex_1 (cost=0.43..8.45 rows=1 width=32) (actual time=0.016..0.017 rows=1 loops=1)
Index Cond: (place_id = 412369)
Buffers: shared hit=4
Planning time: 0.301 ms
Execution time: 497.530 ms
# second query
Nested Loop (cost=10.10..711.03 rows=1 width=568) (actual time=610.755..2782.035 rows=25 loops=1)
Buffers: shared hit=152161
-> Index Scan using idx_place_id on placex place (cost=0.43..8.45 rows=1 width=286) (actual time=0.014..0.016 rows=1 loops=1)
Index Cond: (place_id = 412369)
Buffers: shared hit=4
-> Bitmap Heap Scan on placex same (cost=9.67..702.57 rows=1 width=568) (actual time=610.734..2781.976 rows=25 loops=1)
Recheck Cond: (geometry && st_expand(place.geometry, '300'::double precision))
Filter: ((place.geometry && st_expand(geometry, '300'::double precision)) AND ((place.name -> 'name'::text) = (name -> 'name'::text)) AND _st_dwithin(geometry, place.geometry, '300'::double precision))
Rows Removed by Filter: 1666525
Heap Blocks: exact=90644
Buffers: shared hit=152157
-> Bitmap Index Scan on idx_placex_geometry (cost=0.00..9.67 rows=167 width=0) (actual time=305.126..305.126 rows=1731640 loops=1)
Index Cond: (geometry && st_expand(place.geometry, '300'::double precision))
Buffers: shared hit=19712
Planning time: 0.347 ms
Execution time: 2782.106 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment