explain.depesz.com

PostgreSQL's explain analyze made readable

Result: E3o

Settings
# exclusive inclusive rows x rows loops node
1. 0.137 8,357.237 ↑ 1.0 100 1

Limit (cost=2,466,148.31..2,466,148.56 rows=100 width=41) (actual time=8,357.095..8,357.237 rows=100 loops=1)

2. 22.045 8,357.100 ↑ 3,401.3 100 1

Sort (cost=2,466,148.31..2,466,998.64 rows=340,131 width=41) (actual time=8,357.094..8,357.100 rows=100 loops=1)

  • Sort Key: (sum(CASE WHEN vp.is_promoted THEN 1 ELSE 0 END)) DESC
  • Sort Method: top-N heapsort Memory: 34kB
3. 166.060 8,335.055 ↑ 1.9 179,015 1

Finalize HashAggregate (cost=2,449,747.44..2,453,148.75 rows=340,131 width=41) (actual time=8,290.154..8,335.055 rows=179,015 loops=1)

  • Group Key: v_1.channel_id
4. 55.080 8,168.995 ↑ 4.4 307,270 1

Gather (cost=2,300,089.80..2,439,543.51 rows=1,360,524 width=41) (actual time=8,105.812..8,168.995 rows=307,270 loops=1)

  • Workers Planned: 4
  • Workers Launched: 4
5. 196.723 8,113.915 ↑ 5.5 61,454 5

Partial HashAggregate (cost=2,299,089.80..2,302,491.11 rows=340,131 width=41) (actual time=8,097.228..8,113.915 rows=61,454 loops=5)

  • Group Key: v_1.channel_id
6. 7,392.553 7,917.192 ↑ 1.3 649,276 5

Nested Loop Left Join (cost=0.70..2,292,859.12 rows=830,757 width=26) (actual time=0.048..7,917.192 rows=649,276 loops=5)

7. 0.000 524.628 ↑ 1.3 649,276 5

Parallel Append (cost=0.12..144,292.76 rows=830,757 width=37) (actual time=0.024..524.628 rows=649,276 loops=5)

8. 260.782 260.782 ↑ 1.3 331,070 5

Parallel Index Only Scan using videos_y2019_q3_channel_id_published_id_view_count_comment__idx on videos_y2019_q3 v_1 (cost=0.56..85,628.16 rows=429,504 width=37) (actual time=0.026..260.782 rows=331,070 loops=5)

  • Index Cond: ((published >= '2019-06-01 00:00:00+00'::timestamp with time zone) AND (published <= '2019-08-01 00:00:00+00'::timestamp with time zone))
  • Heap Fetches: 0
9. 347.541 347.541 ↓ 1.3 530,343 3

Parallel Index Only Scan using videos_y2019_m05_channel_id_published_id_view_count_comment_idx on videos_y2019_m05 v (cost=0.55..54,509.58 rows=401,253 width=37) (actual time=0.020..347.541 rows=530,343 loops=3)

  • Index Cond: ((published >= '2019-06-01 00:00:00+00'::timestamp with time zone) AND (published <= '2019-08-01 00:00:00+00'::timestamp with time zone))
  • Heap Fetches: 0
10. 0.005 0.005 ↓ 0.0 0 1

Parallel Index Only Scan using videos_default_channel_id_published_id_view_count_comment_c_idx on videos_default v_2 (cost=0.12..1.24 rows=1 width=44) (actual time=0.005..0.005 rows=0 loops=1)

  • Index Cond: ((published >= '2019-06-01 00:00:00+00'::timestamp with time zone) AND (published <= '2019-08-01 00:00:00+00'::timestamp with time zone))
  • Heap Fetches: 0
11. 0.011 0.011 ↑ 1.0 1 3,246,381

Index Scan using video_promotion_pkey on video_promotion vp (cost=0.57..2.59 rows=1 width=13) (actual time=0.011..0.011 rows=1 loops=3,246,381)

  • Index Cond: (v_1.id = youtube_video_id)
Planning time : 1.803 ms