explain.depesz.com

PostgreSQL's explain analyze made readable

Result: dODg

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 83.688 ↑ 1.0 10 1

Limit (cost=7,235.93..7,235.96 rows=10 width=12) (actual time=83.686..83.688 rows=10 loops=1)

  • Buffers: shared hit=12 read=926
2. 14.284 83.685 ↑ 10,000.0 10 1

Sort (cost=7,235.93..7,485.93 rows=100,000 width=12) (actual time=83.685..83.685 rows=10 loops=1)

  • Sort Key: (COALESCE(count(likes.video_id), '0'::bigint)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=12 read=926
3. 25.754 69.401 ↑ 1.0 100,000 1

GroupAggregate (cost=67.71..5,074.97 rows=100,000 width=12) (actual time=1.813..69.401 rows=100,000 loops=1)

  • Group Key: video.video_id
  • Buffers: shared hit=9 read=926
4. 13.710 43.647 ↑ 1.0 100,000 1

Merge Left Join (cost=67.71..3,574.97 rows=100,000 width=8) (actual time=1.806..43.647 rows=100,000 loops=1)

  • Merge Cond: (video.video_id = likes.video_id)
  • Buffers: shared hit=9 read=926
5. 28.173 28.173 ↑ 1.0 100,000 1

Index Only Scan using video_pkey on video (cost=0.29..3,257.48 rows=100,000 width=4) (actual time=0.036..28.173 rows=100,000 loops=1)

  • Heap Fetches: 100000
  • Buffers: shared hit=9 read=920
6. 0.016 1.764 ↑ 5.0 1 1

Sort (cost=67.42..67.43 rows=5 width=4) (actual time=1.764..1.764 rows=1 loops=1)

  • Sort Key: likes.video_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared read=6
7. 0.018 1.748 ↑ 5.0 1 1

Nested Loop (cost=4.02..67.36 rows=5 width=4) (actual time=1.746..1.748 rows=1 loops=1)

  • Buffers: shared read=6
8. 1.053 1.053 ↑ 4.0 1 1

Index Scan using friend_index on friend (cost=0.00..20.07 rows=4 width=4) (actual time=1.052..1.053 rows=1 loops=1)

  • Index Cond: (user_id = 1)
  • Buffers: shared read=3
9. 0.187 0.677 ↑ 2.0 1 1

Bitmap Heap Scan on likes (cost=4.02..11.80 rows=2 width=8) (actual time=0.677..0.677 rows=1 loops=1)

  • Recheck Cond: (user_id = friend.friend_id)
  • Heap Blocks: exact=1
  • Buffers: shared read=3
10. 0.490 0.490 ↑ 2.0 1 1

Bitmap Index Scan on user_index (cost=0.00..4.01 rows=2 width=0) (actual time=0.489..0.490 rows=1 loops=1)

  • Index Cond: (user_id = friend.friend_id)
  • Buffers: shared read=2