explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YS49W : stage_status

Settings
# exclusive inclusive rows x rows loops node
1. 76.704 46,667.085 ↑ 27,979.1 41,440 1

Hash Join (cost=521,286,673.96..683,609,990.64 rows=1,159,452,262 width=264) (actual time=46,317.135..46,667.085 rows=41,440 loops=1)

  • Hash Cond: (rim.run_id = lrid.run_id)
2.          

CTE latest_run_id_dates

3. 0.039 91.694 ↑ 6.2 32 1

HashAggregate (cost=1,882,595.83..1,882,597.83 rows=200 width=8) (actual time=91.684..91.694 rows=32 loops=1)

  • Group Key: r_1.date
4. 0.413 91.655 ↑ 210.0 64 1

HashAggregate (cost=1,882,259.83..1,882,394.23 rows=13,440 width=86) (actual time=91.612..91.655 rows=64 loops=1)

  • Group Key: cm.level0top, rim_1.blueprint_id, rim_1.run_id, rim_1.backfill, rim_1.birthdate, r_1.date, rim_1.cancelled, m_1.valid_range, m_1.version, m_1.active_date_range, m_1.active
5. 2.238 91.242 ↑ 105.0 320 1

HashAggregate (cost=1,880,663.87..1,880,999.86 rows=33,599 width=118) (actual time=91.046..91.242 rows=320 loops=1)

  • Group Key: cm.level0top, rim_1.blueprint_id, rim_1.run_id, rim_1.backfill, rim_1.birthdate, r_1.date, rim_1.cancelled, s_1.stage, m_1.version, m_1.valid_range, m_1.active_date_range, m_1.active
6.          

CTE stages

7. 0.009 0.009 ↑ 20.0 5 1

Function Scan on unnest (cost=0.00..1.00 rows=100 width=32) (actual time=0.008..0.009 rows=5 loops=1)

8.          

CTE run_dates

9. 48.347 48.347 ↑ 1,180.8 51,849 1

Seq Scan on run_id_mapping (cost=0.00..307,493.35 rows=61,223,000 width=12) (actual time=0.039..48.347 rows=51,849 loops=1)

10. 1.833 89.004 ↑ 21.1 1,595 1

Nested Loop Left Join (cost=1,324.13..1,572,161.56 rows=33,599 width=118) (actual time=18.000..89.004 rows=1,595 loops=1)

  • Join Filter: (log_1.state = s_1.stage)
  • Rows Removed by Join Filter: 6380
11. 0.142 83.651 ↑ 105.0 320 1

Nested Loop (cost=1,323.58..1,533,472.70 rows=33,599 width=118) (actual time=17.904..83.651 rows=320 loops=1)

12. 0.014 0.014 ↑ 20.0 5 1

CTE Scan on stages s_1 (cost=0.00..2.00 rows=100 width=32) (actual time=0.009..0.014 rows=5 loops=1)

13. 0.085 83.495 ↑ 5.2 64 5

Materialize (cost=1,323.58..1,533,051.54 rows=336 width=86) (actual time=3.579..16.699 rows=64 loops=5)

14. 0.636 83.410 ↑ 5.2 64 1

Hash Join (cost=1,323.58..1,533,049.86 rows=336 width=86) (actual time=17.891..83.410 rows=64 loops=1)

  • Hash Cond: (r_1.run_id = rim_1.run_id)
15. 70.386 70.386 ↑ 99.1 3,090 1

CTE Scan on run_dates r_1 (cost=0.00..1,530,575.00 rows=306,115 width=8) (actual time=0.640..70.386 rows=3,090 loops=1)

  • Filter: ((date >= '2019-01-01'::date) AND (date <= '2019-02-01'::date))
  • Rows Removed by Filter: 48759
16. 0.053 12.388 ↓ 2.0 135 1

Hash (cost=1,322.74..1,322.74 rows=67 width=82) (actual time=12.388..12.388 rows=135 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
17. 0.045 12.335 ↓ 2.0 135 1

Nested Loop (cost=17.57..1,322.74 rows=67 width=82) (actual time=0.842..12.335 rows=135 loops=1)

18. 0.011 0.011 ↑ 1.0 1 1

Index Scan using master_idx on master m_1 (cost=0.14..2.16 rows=1 width=56) (actual time=0.010..0.011 rows=1 loops=1)

  • Index Cond: (level0top = 'VID_NESTLE_MASTER_1'::text)
19. 4.637 12.279 ↓ 2.0 135 1

Hash Join (cost=17.43..1,319.91 rows=67 width=47) (actual time=0.829..12.279 rows=135 loops=1)

  • Hash Cond: (rim_1.blueprint_id = cm.version)
20. 7.596 7.596 ↑ 2.1 29,195 1

Seq Scan on run_id_mapping rim_1 (cost=0.00..1,072.23 rows=61,223 width=25) (actual time=0.009..7.596 rows=29,195 loops=1)

21. 0.003 0.046 ↑ 3.5 4 1

Hash (cost=17.25..17.25 rows=14 width=30) (actual time=0.046..0.046 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
22. 0.004 0.043 ↑ 3.5 4 1

Subquery Scan on cm (cost=17.08..17.25 rows=14 width=30) (actual time=0.040..0.043 rows=4 loops=1)

23. 0.020 0.039 ↑ 3.5 4 1

Sort (cost=17.08..17.11 rows=14 width=105) (actual time=0.039..0.039 rows=4 loops=1)

  • Sort Key: master_2.level0top, master_2.version DESC
  • Sort Method: quicksort Memory: 25kB
24. 0.004 0.019 ↑ 3.5 4 1

Append (cost=0.14..16.81 rows=14 width=105) (actual time=0.005..0.019 rows=4 loops=1)

25. 0.004 0.004 ↑ 1.0 1 1

Index Scan using master_idx on master master_2 (cost=0.14..2.16 rows=1 width=86) (actual time=0.004..0.004 rows=1 loops=1)

  • Index Cond: (level0top = 'VID_NESTLE_MASTER_1'::text)
26. 0.011 0.011 ↑ 4.3 3 1

Index Scan using master_version_history_idx on master master_3 (cost=0.29..14.51 rows=13 width=105) (actual time=0.008..0.011 rows=3 loops=1)

  • Index Cond: (level0top = 'VID_NESTLE_MASTER_1'::text)
27. 3.520 3.520 ↓ 25.0 25 320

Index Only Scan using run_log_pkey on run_log log_1 (cost=0.56..1.14 rows=1 width=14) (actual time=0.005..0.011 rows=25 loops=320)

  • Index Cond: ((date = r_1.date) AND (run_id = rim_1.run_id))
  • Heap Fetches: 0
28. 3,819.829 46,498.660 ↑ 7,791.8 148,805 1

GroupAggregate (cost=519,404,069.64..626,653,403.87 rows=1,159,452,262 width=329) (actual time=41,881.826..46,498.660 rows=148,805 loops=1)

  • Group Key: master.level0top, rim.blueprint_id, rim.run_id, rim.backfill, rim.birthdate, r.date, rim.cancelled, s.stage, m.version, m.valid_range, m.active_date_range, m.active
29.          

CTE stages

30. 0.018 0.018 ↑ 20.0 5 1

Function Scan on unnest unnest_1 (cost=0.00..1.00 rows=100 width=32) (actual time=0.017..0.018 rows=5 loops=1)

31.          

CTE run_dates

32. 53.890 53.890 ↑ 1,180.8 51,849 1

Seq Scan on run_id_mapping run_id_mapping_1 (cost=0.00..307,493.35 rows=61,223,000 width=12) (actual time=0.064..53.890 rows=51,849 loops=1)

33. 14,621.293 42,678.831 ↑ 1,214.5 954,697 1

Sort (cost=519,096,575.29..521,995,205.94 rows=1,159,452,262 width=329) (actual time=41,881.699..42,678.831 rows=954,697 loops=1)

  • Sort Key: master.level0top, rim.blueprint_id, rim.run_id, rim.backfill, rim.birthdate, r.date, rim.cancelled, s.stage, m.version, m.valid_range, m.active_date_range, m.active
  • Sort Method: external merge Disk: 179784kB
34. 1,843.571 28,057.538 ↑ 1,214.5 954,697 1

Merge Left Join (cost=230,960,390.66..242,631,437.03 rows=1,159,452,262 width=329) (actual time=25,902.404..28,057.538 rows=954,697 loops=1)

  • Merge Cond: ((r.date = log.date) AND (rim.run_id = log.run_id) AND (s.stage = log.state))
35. 215.216 539.424 ↑ 7,788.1 148,875 1

Sort (cost=229,784,933.53..232,683,564.18 rows=1,159,452,262 width=118) (actual time=489.569..539.424 rows=148,875 loops=1)

  • Sort Key: r.date, rim.run_id, s.stage
  • Sort Method: quicksort Memory: 27198kB
36. 92.524 324.208 ↑ 7,788.1 148,875 1

Hash Right Join (cost=36,701.52..14,462,785.27 rows=1,159,452,262 width=118) (actual time=159.196..324.208 rows=148,875 loops=1)

  • Hash Cond: (r.run_id = rim.run_id)
37. 77.859 77.859 ↑ 1,180.8 51,849 1

CTE Scan on run_dates r (cost=0.00..1,224,460.00 rows=61,223,000 width=8) (actual time=0.066..77.859 rows=51,849 loops=1)

38. 38.738 153.825 ↑ 12.8 90,690 1

Hash (cost=22,208.37..22,208.37 rows=1,159,452 width=114) (actual time=153.825..153.825 rows=90,690 loops=1)

  • Buckets: 2097152 Batches: 1 Memory Usage: 27066kB
39. 32.422 115.087 ↑ 12.8 90,690 1

Nested Loop (cost=7,250.72..22,208.37 rows=1,159,452 width=114) (actual time=48.009..115.087 rows=90,690 loops=1)

40. 0.025 0.025 ↑ 20.0 5 1

CTE Scan on stages s (cost=0.00..2.00 rows=100 width=32) (actual time=0.018..0.025 rows=5 loops=1)

41. 19.682 82.640 ↓ 1.6 18,138 5

Materialize (cost=7,250.72..7,742.85 rows=11,594 width=82) (actual time=9.598..16.528 rows=18,138 loops=5)

42. 8.582 62.958 ↓ 1.6 18,138 1

Merge Join (cost=7,250.72..7,684.88 rows=11,594 width=82) (actual time=47.985..62.958 rows=18,138 loops=1)

  • Merge Cond: (master.version = rim.blueprint_id)
43. 3.461 31.409 ↓ 2.4 5,696 1

Sort (cost=1,310.71..1,316.75 rows=2,416 width=65) (actual time=30.347..31.409 rows=5,696 loops=1)

  • Sort Key: master.version
  • Sort Method: quicksort Memory: 994kB
44. 5.551 27.948 ↓ 2.4 5,696 1

Merge Join (cost=984.53..1,174.95 rows=2,416 width=65) (actual time=20.425..27.948 rows=5,696 loops=1)

  • Merge Cond: (master.level0top = m.level0top)
45. 17.741 21.389 ↑ 1.6 6,399 1

Sort (cost=979.75..1,005.45 rows=10,279 width=106) (actual time=20.339..21.389 rows=6,399 loops=1)

  • Sort Key: master.level0top, master.version DESC
  • Sort Method: quicksort Memory: 1464kB
46. 1.518 3.648 ↑ 1.6 6,399 1

Append (cost=0.00..294.79 rows=10,279 width=106) (actual time=0.008..3.648 rows=6,399 loops=1)

47. 0.024 0.024 ↑ 1.0 47 1

Seq Scan on master (cost=0.00..3.47 rows=47 width=87) (actual time=0.008..0.024 rows=47 loops=1)

48. 2.106 2.106 ↑ 1.6 6,352 1

Seq Scan on master master_1 (cost=0.00..291.32 rows=10,232 width=106) (actual time=0.004..2.106 rows=6,352 loops=1)

49. 0.999 1.008 ↓ 121.2 5,696 1

Sort (cost=4.78..4.89 rows=47 width=56) (actual time=0.081..1.008 rows=5,696 loops=1)

  • Sort Key: m.level0top
  • Sort Method: quicksort Memory: 31kB
50. 0.009 0.009 ↑ 1.0 47 1

Seq Scan on master m (cost=0.00..3.47 rows=47 width=56) (actual time=0.003..0.009 rows=47 loops=1)

51. 15.082 22.967 ↑ 2.5 24,224 1

Sort (cost=5,940.01..6,093.06 rows=61,223 width=25) (actual time=17.579..22.967 rows=24,224 loops=1)

  • Sort Key: rim.blueprint_id
  • Sort Method: quicksort Memory: 3049kB
52. 7.885 7.885 ↑ 2.1 29,195 1

Seq Scan on run_id_mapping rim (cost=0.00..1,072.23 rows=61,223 width=25) (actual time=0.030..7.885 rows=29,195 loops=1)

53. 1,806.330 25,674.543 ↑ 1.0 5,952,046 1

Materialize (cost=1,175,457.13..1,205,384.09 rows=5,985,393 width=225) (actual time=19,040.636..25,674.543 rows=5,952,046 loops=1)

54. 21,878.593 23,868.213 ↑ 1.0 5,940,402 1

Sort (cost=1,175,457.13..1,190,420.61 rows=5,985,393 width=225) (actual time=19,040.628..23,868.213 rows=5,940,402 loops=1)

  • Sort Key: log.date, log.run_id, log.state
  • Sort Method: external merge Disk: 415680kB
55. 1,989.620 1,989.620 ↑ 1.0 5,940,402 1

Seq Scan on run_log log (cost=0.00..127,622.93 rows=5,985,393 width=225) (actual time=0.009..1,989.620 rows=5,940,402 loops=1)

56. 0.013 91.721 ↑ 6.2 32 1

Hash (cost=4.00..4.00 rows=200 width=8) (actual time=91.721..91.721 rows=32 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
57. 91.708 91.708 ↑ 6.2 32 1

CTE Scan on latest_run_id_dates lrid (cost=0.00..4.00 rows=200 width=8) (actual time=91.686..91.708 rows=32 loops=1)

Planning time : 3.475 ms
Execution time : 46,773.820 ms