Skip to content

Instantly share code, notes, and snippets.

Created February 15, 2018 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/32ed485b40cce2651ddc52661f3e7f7b to your computer and use it in GitHub Desktop.
Save anonymous/32ed485b40cce2651ddc52661f3e7f7b to your computer and use it in GitHub Desktop.
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=98624.84..98624.96 rows=10 width=74) (actual time=8234.723..8234.816 rows=10 loops=1)
Buffers: shared hit=10314 read=2 dirtied=1
-> Sort (cost=98624.84..99874.84 rows=500000 width=74) (actual time=8234.713..8234.740 rows=10 loops=1)
Sort Key: posts.id DESC
Sort Method: top-N heapsort Memory: 26kB
Buffers: shared hit=10314 read=2 dirtied=1
-> Hash Join (cost=17.92..29077.92 rows=500000 width=74) (actual time=1.381..7835.510 rows=100742 loops=1)
Hash Cond: (posts.user_id = users.id)
Buffers: shared hit=10314 read=2 dirtied=1
-> Seq Scan on posts (cost=0.00..20310.00 rows=1000000 width=49) (actual time=0.019..3707.714 rows=1000000 loops=1)
Buffers: shared hit=10310
-> Hash (cost=17.29..17.29 rows=50 width=49) (actual time=1.324..1.324 rows=10 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 9kB
Buffers: shared hit=4 read=2 dirtied=1
-> Hash Join (cost=14.88..17.29 rows=50 width=49) (actual time=0.222..1.264 rows=10 loops=1)
Hash Cond: (users.id = friends.friend_user_id)
Buffers: shared hit=4 read=2 dirtied=1
-> Seq Scan on users (cost=0.00..2.00 rows=100 width=41) (actual time=0.009..0.509 rows=100 loops=1)
Buffers: shared hit=1
-> Hash (cost=14.76..14.76 rows=9 width=8) (actual time=0.180..0.180 rows=10 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 9kB
Buffers: shared hit=3 read=2 dirtied=1
-> Bitmap Heap Scan on friends (cost=4.22..14.76 rows=9 width=8) (actual time=0.062..0.113 rows=10 loops=1)
Recheck Cond: (user_id = 1)
Heap Blocks: exact=1
Buffers: shared hit=3 read=2 dirtied=1
-> Bitmap Index Scan on friends_user_id_friend_user_id_key (cost=0.00..4.22 rows=9 width=0) (actual time=0.040..0.040 rows=10 loops=1)
Index Cond: (user_id = 1)
Buffers: shared hit=3 read=1
Planning time: 0.839 ms
Execution time: 8234.921 ms
(31 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment