Skip to content

Instantly share code, notes, and snippets.

@saikat
Created December 27, 2015 17:58
Show Gist options
  • Save saikat/ba694c07fb7fa97e8190 to your computer and use it in GitHub Desktop.
Save saikat/ba694c07fb7fa97e8190 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" = -7
and "bsd_addresses"."is_primary" = 'true'
limit '1';
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.84..9.19 rows=1 width=8) (actual time=0.156..0.156 rows=1 loops=1)
-> Nested Loop (cost=0.84..2196698.32 rows=263003 width=8) (actual time=0.155..0.155 rows=1 loops=1)
-> Nested Loop (cost=0.29..1906153.63 rows=355247 width=8) (actual time=0.130..0.130 rows=1 loops=1)
-> Seq Scan on bsd_addresses (cost=0.00..392335.32 rows=4686556 width=13) (actual time=0.108..0.108 rows=1 loops=1)
Filter: is_primary
-> Index Scan using zip_codes_zip_index on zip_codes (cost=0.29..0.31 rows=1 width=6) (actual time=0.018..0.018 rows=1 loops=1)
Index Cond: ((zip)::text = (bsd_addresses.zip)::text)
Filter: (timezone_offset = (-7))
-> 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.022..0.022 rows=1 loops=1)
Index Cond: (cons_id = bsd_addresses.cons_id)
Heap Fetches: 1
Planning time: 0.503 ms
Execution time: 0.194 ms
(13 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment