Skip to content

Instantly share code, notes, and snippets.

@seantalts
Created March 19, 2013 23:26
Show Gist options
  • Save seantalts/5201077 to your computer and use it in GitHub Desktop.
Save seantalts/5201077 to your computer and use it in GitHub Desktop.
feed_insights=# explain select count(distinct(user_id)) from interests where keywords in (select keywords from interests group by keywords having count(*) > 30);
QUERY PLAN
---------------------------------------------------------------------------------------------------
Aggregate (cost=2232807.48..2232807.49 rows=1 width=4)
-> Hash Join (cost=1780566.44..2221413.32 rows=4557663 width=4)
Hash Cond: (public.interests.keywords = public.interests.keywords)
-> Seq Scan on interests (cost=0.00..172441.36 rows=9188836 width=19)
-> Hash (cost=1778239.13..1778239.13 rows=133865 width=15)
-> GroupAggregate (cost=1706310.89..1776900.48 rows=133865 width=15)
Filter: (count(*) > 30)
-> Sort (cost=1706310.89..1729282.98 rows=9188836 width=15)
Sort Key: public.interests.keywords
-> Seq Scan on interests (cost=0.00..172441.36 rows=9188836 width=15)
(10 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment