Skip to content

Instantly share code, notes, and snippets.

@rueian
Created December 21, 2019 18:02
Show Gist options
  • Save rueian/ae00a29e7ee8b662235949c4eecd4a92 to your computer and use it in GitHub Desktop.
Save rueian/ae00a29e7ee8b662235949c4eecd4a92 to your computer and use it in GitHub Desktop.
HashAggregate.5.sql
postgres=#
EXPLAIN SELECT * FROM devices WHERE user_id IN (SELECT user_id FROM playlist_subscriptions WHERE list_id = 3343594);
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=32995.28..241867.55 rows=294585 width=170)
Hash Cond: (devices.user_id = playlist_subscriptions.user_id)
-> Seq Scan on devices (cost=0.00..194390.62 rows=5516762 width=170)
-> Hash (cost=32705.43..32705.43 rows=23188 width=8)
-> Bitmap Heap Scan on playlist_subscriptions (cost=1350.13..32705.43 rows=23188 width=8)
Recheck Cond: (list_id = 3343594)
-> Bitmap Index Scan on playlist_subscriptions_list_id_user_id_uniq (cost=0.00..1344.34 rows=23188 width=0)
Index Cond: (list_id = 3343594)
(8 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment