explain.depesz.com

PostgreSQL's explain analyze made readable

Result: npz8

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 789.691 ↑ 1.0 10 1

Limit (cost=172,317.02..172,317.04 rows=10 width=12) (actual time=789.687..789.691 rows=10 loops=1)

  • Buffers: shared hit=74605
2. 1.093 789.689 ↑ 140.4 10 1

Sort (cost=172,317.02..172,320.53 rows=1,404 width=12) (actual time=789.687..789.689 rows=10 loops=1)

  • Sort Key: ((SubPlan 1)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=74605
3. 3.046 788.596 ↓ 2.8 4,000 1

Group (cost=0.28..172,286.68 rows=1,404 width=12) (actual time=0.407..788.596 rows=4,000 loops=1)

  • Group Key: v.video_id
  • Buffers: shared hit=74605
4. 1.550 1.550 ↓ 2.8 4,000 1

Index Only Scan using video_pkey on video v (cost=0.28..177.34 rows=1,404 width=4) (actual time=0.015..1.550 rows=4,000 loops=1)

  • Heap Fetches: 4000
  • Buffers: shared hit=38
5.          

SubPlan (forGroup)

6. 12.000 784.000 ↑ 1.0 1 4,000

Aggregate (cost=122.57..122.58 rows=1 width=8) (actual time=0.196..0.196 rows=1 loops=4,000)

  • Buffers: shared hit=74567
7. 7.893 772.000 ↓ 0.0 0 4,000

Hash Join (cost=34.49..122.57 rows=1 width=4) (actual time=0.193..0.193 rows=0 loops=4,000)

  • Hash Cond: (f.friend_id = l.user_id)
  • Buffers: shared hit=74567
8. 376.107 376.107 ↑ 2.2 12 1,329

Seq Scan on friend f (cost=0.00..87.98 rows=26 width=4) (actual time=0.111..0.283 rows=12 loops=1,329)

  • Filter: (user_id = $1)
  • Rows Removed by Filter: 4988
  • Buffers: shared hit=30567
9. 8.000 388.000 ↓ 0.0 0 4,000

Hash (cost=34.38..34.38 rows=9 width=8) (actual time=0.097..0.097 rows=0 loops=4,000)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=44000
10. 380.000 380.000 ↓ 0.0 0 4,000

Seq Scan on likes l (cost=0.00..34.38 rows=9 width=8) (actual time=0.078..0.095 rows=0 loops=4,000)

  • Filter: (video_id = v.video_id)
  • Rows Removed by Filter: 1600
  • Buffers: shared hit=44000
Planning time : 0.131 ms
Execution time : 789.730 ms