Skip to content

Instantly share code, notes, and snippets.

@saikat
Last active December 27, 2015 17:57
Show Gist options
  • Save saikat/a70e85b460ee08eddc8f to your computer and use it in GitHub Desktop.
Save saikat/a70e85b460ee08eddc8f to your computer and use it in GitHub Desktop.
> explain analyze
select "bsd_people"."cons_id" from "bsd_person_gc_bsd_groups" as "bsd_people"
inner join "bsd_addresses" on "bsd_people"."cons_id" = "bsd_addresses"."cons_id"
inner join "zip_codes" on "zip_codes"."zip" = "bsd_addresses"."zip"
where
"zip_codes"."timezone_offset" = -4
and "bsd_addresses"."is_primary" = 'true'
limit '1';
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=20.42..41.64 rows=1 width=8) (actual time=733.180..733.180 rows=0 loops=1)
-> Nested Loop (cost=20.42..367177.79 rows=17299 width=8) (actual time=733.178..733.178 rows=0 loops=1)
-> Nested Loop (cost=19.87..348067.52 rows=23366 width=8) (actual time=0.040..682.881 rows=5885 loops=1)
-> Seq Scan on zip_codes (cost=0.00..1019.89 rows=216 width=6) (actual time=0.008..5.647 rows=222 loops=1)
Filter: (timezone_offset = (-4))
Rows Removed by Filter: 42969
-> Bitmap Heap Scan on bsd_addresses (cost=19.87..1603.16 rows=354 width=13) (actual time=0.124..3.037 rows=27 loops=222)
Recheck Cond: ((zip)::text = (zip_codes.zip)::text)
Filter: is_primary
Rows Removed by Filter: 6
Heap Blocks: exact=6318
-> Bitmap Index Scan on bsd_addresses_zip_index (cost=0.00..19.78 rows=466 width=0) (actual time=0.014..0.014 rows=32 loops=222)
Index Cond: ((zip)::text = (zip_codes.zip)::text)
-> Index Only Scan using bsd_person_gc_bsd_groups_cons_id_index on bsd_person_gc_bsd_groups bsd_people (cost=0.55..0.81 rows=1 width=8) (actual time=0.008..0.008 rows=0 loops=5885)
Index Cond: (cons_id = bsd_addresses.cons_id)
Heap Fetches: 0
Planning time: 0.516 ms
Execution time: 733.227 ms
(18 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment