explain.depesz.com

PostgreSQL's explain analyze made readable

Result: lt0y

Settings
# exclusive inclusive rows x rows loops node
1. 0.666 393.798 ↑ 128.2 13 1

Subquery Scan on t (cost=20,101.67..20,251.67 rows=1,667 width=12) (actual time=385.874..393.798 rows=13 loops=1)

  • Filter: (t.rk <= 10)
  • Rows Removed by Filter: 4987
2. 6.587 393.132 ↑ 1.0 5,000 1

WindowAgg (cost=20,101.67..20,189.17 rows=5,000 width=20) (actual time=385.871..393.132 rows=5,000 loops=1)

3. 2.164 386.545 ↑ 1.0 5,000 1

Sort (cost=20,101.67..20,114.17 rows=5,000 width=12) (actual time=385.793..386.545 rows=5,000 loops=1)

  • Sort Key: (COALESCE(r1.rank, '0'::bigint)) DESC
  • Sort Method: quicksort Memory: 427kB
4. 2.292 384.381 ↑ 1.0 5,000 1

Hash Left Join (cost=19,698.35..19,794.48 rows=5,000 width=12) (actual time=381.510..384.381 rows=5,000 loops=1)

  • Hash Cond: (v.video_id = r1.vid)
5. 0.654 0.654 ↑ 1.0 5,000 1

Seq Scan on video v (cost=0.00..83.00 rows=5,000 width=4) (actual time=0.026..0.654 rows=5,000 loops=1)

6. 1.335 381.435 ↑ 1.0 4,993 1

Hash (cost=19,635.87..19,635.87 rows=4,998 width=12) (actual time=381.435..381.435 rows=4,993 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 279kB
7. 0.624 380.100 ↑ 1.0 4,993 1

Subquery Scan on r1 (cost=19,535.91..19,635.87 rows=4,998 width=12) (actual time=377.939..380.100 rows=4,993 loops=1)

8. 10.003 379.476 ↑ 1.0 4,993 1

Finalize HashAggregate (cost=19,535.91..19,585.89 rows=4,998 width=12) (actual time=377.938..379.476 rows=4,993 loops=1)

  • Group Key: l.video_id
9. 106.165 369.473 ↓ 1.5 14,979 1

Gather (cost=18,436.35..19,485.93 rows=9,996 width=12) (actual time=363.078..369.473 rows=14,979 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
10. 104.706 263.308 ↑ 1.0 4,993 3

Partial HashAggregate (cost=17,436.35..17,486.33 rows=4,998 width=12) (actual time=260.484..263.308 rows=4,993 loops=3)

  • Group Key: l.video_id
11. 31.302 158.602 ↑ 1.2 166,427 3

Hash Anti Join (cost=5,883.70..16,398.30 rows=207,611 width=4) (actual time=42.606..158.602 rows=166,427 loops=3)

  • Hash Cond: (l.video_id = w.video_id)
12. 52.379 126.062 ↑ 1.2 166,464 3

Parallel Hash Anti Join (cost=5,789.19..13,682.54 rows=207,653 width=4) (actual time=41.352..126.062 rows=166,464 loops=3)

  • Hash Cond: (l.video_id = l_user.video_id)
13. 32.430 32.430 ↑ 1.2 166,667 3

Parallel Seq Scan on likes l (cost=0.00..5,268.33 rows=208,333 width=4) (actual time=0.017..32.430 rows=166,667 loops=3)

14. 0.000 41.253 ↑ 1.0 2 3

Parallel Hash (cost=5,789.17..5,789.17 rows=2 width=4) (actual time=41.252..41.253 rows=2 loops=3)

  • Buckets: 1024 Batches: 1 Memory Usage: 72kB
15. 61.736 61.736 ↓ 1.5 3 2

Parallel Seq Scan on likes l_user (cost=0.00..5,789.17 rows=2 width=4) (actual time=36.590..61.736 rows=3 loops=2)

  • Filter: (user_id = 10)
  • Rows Removed by Filter: 249997
16. 0.020 1.238 ↑ 1.0 1 3

Hash (cost=94.50..94.50 rows=1 width=4) (actual time=1.238..1.238 rows=1 loops=3)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
17. 1.218 1.218 ↑ 1.0 1 3

Seq Scan on watch w (cost=0.00..94.50 rows=1 width=4) (actual time=1.153..1.218 rows=1 loops=3)

  • Filter: (user_id = 10)
  • Rows Removed by Filter: 4999