explain.depesz.com

PostgreSQL's explain analyze made readable

Result: dxeW

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 475.752 ↑ 1.0 10 1

Limit (cost=55,161.51..55,161.53 rows=10 width=16) (actual time=475.747..475.752 rows=10 loops=1)

  • Buffers: shared hit=44041
2. 0.866 475.748 ↑ 140.4 10 1

Sort (cost=55,161.51..55,165.02 rows=1,404 width=16) (actual time=475.746..475.748 rows=10 loops=1)

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

Group (cost=0.55..55,131.17 rows=1,404 width=16) (actual time=0.161..474.882 rows=4,000 loops=1)

  • Group Key: v.video_id, u.user_id
  • Buffers: shared hit=44041
4. 1.864 3.309 ↓ 2.8 4,000 1

Nested Loop (cost=0.55..203.18 rows=1,404 width=8) (actual time=0.024..3.309 rows=4,000 loops=1)

  • Buffers: shared hit=41
5. 1.445 1.445 ↓ 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.009..1.445 rows=4,000 loops=1)

  • Heap Fetches: 4000
  • Buffers: shared hit=38
6. 0.000 0.000 ↑ 1.0 1 4,000

Materialize (cost=0.27..8.30 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=4,000)

  • Buffers: shared hit=3
7. 0.014 0.014 ↑ 1.0 1 1

Index Only Scan using users_pkey on users u (cost=0.27..8.29 rows=1 width=4) (actual time=0.013..0.014 rows=1 loops=1)

  • Index Cond: (user_id = $1)
  • Heap Fetches: 1
  • Buffers: shared hit=3
8.          

SubPlan (forGroup)

9. 16.000 468.000 ↑ 1.0 1 4,000

Aggregate (cost=39.09..39.12 rows=1 width=8) (actual time=0.117..0.117 rows=1 loops=4,000)

  • Buffers: shared hit=44000
10. 452.000 452.000 ↓ 0.0 0 4,000

Seq Scan on likes l (cost=0.00..39.05 rows=9 width=4) (actual time=0.093..0.113 rows=0 loops=4,000)

  • Filter: ((user_id <> u.user_id) AND (v.video_id = video_id))
  • Rows Removed by Filter: 1600
  • Buffers: shared hit=44000