explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Aw56 : stage-status2

Settings
# exclusive inclusive rows x rows loops node
1. 327.469 197,615.958 ↑ 27,979.1 41,440 1

Hash Join (cost=521,267,101.21..683,590,417.89 rows=1,159,452,262 width=264) (actual time=196,223.252..197,615.958 rows=41,440 loops=1)

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

CTE latest_run_id_dates

3. 0.068 507.694 ↑ 6.2 32 1

HashAggregate (cost=1,872,703.83..1,872,705.83 rows=200 width=8) (actual time=507.680..507.694 rows=32 loops=1)

  • Group Key: r_1.date
4. 0.726 507.626 ↑ 210.0 64 1

HashAggregate (cost=1,872,367.83..1,872,502.23 rows=13,440 width=86) (actual time=507.549..507.626 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. 4.067 506.900 ↑ 105.0 320 1

HashAggregate (cost=1,870,771.87..1,871,107.86 rows=33,599 width=118) (actual time=506.486..506.900 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.013 0.013 ↑ 20.0 5 1

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

8.          

CTE run_dates

9. 248.874 248.874 ↑ 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.043..248.874 rows=51,849 loops=1)

10. 8.556 502.833 ↑ 21.1 1,595 1

Nested Loop Left Join (cost=1,324.01..1,562,269.56 rows=33,599 width=118) (actual time=36.937..502.833 rows=1,595 loops=1)

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

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

12. 0.019 0.019 ↑ 20.0 5 1

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

13. 0.194 445.340 ↑ 5.2 64 5

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

14. 1.699 445.146 ↑ 5.2 64 1

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

  • Hash Cond: (r_1.run_id = rim_1.run_id)
15. 418.033 418.033 ↑ 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.869..418.033 rows=3,090 loops=1)

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

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

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
17. 0.118 25.228 ↓ 2.0 135 1

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

18. 0.017 0.017 ↑ 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.015..0.017 rows=1 loops=1)

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

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

  • Hash Cond: (rim_1.blueprint_id = cm.version)
20. 15.149 15.149 ↑ 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.018..15.149 rows=29,195 loops=1)

21. 0.006 0.085 ↑ 3.5 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
22. 0.007 0.079 ↑ 3.5 4 1

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

23. 0.040 0.072 ↑ 3.5 4 1

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

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

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

25. 0.008 0.008 ↑ 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.008..0.008 rows=1 loops=1)

  • Index Cond: (level0top = 'VID_NESTLE_MASTER_1'::text)
26. 0.020 0.020 ↑ 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.014..0.020 rows=3 loops=1)

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

Index Only Scan using run_log_run_id_date_state on run_log log_1 (cost=0.43..0.84 rows=1 width=14) (actual time=0.088..0.152 rows=25 loops=320)

  • Index Cond: ((date = r_1.date) AND (run_id = rim_1.run_id))
  • Heap Fetches: 0
28. 11,425.273 196,780.692 ↑ 7,791.8 148,805 1

GroupAggregate (cost=519,394,388.88..626,643,723.11 rows=1,159,452,262 width=333) (actual time=182,719.303..196,780.692 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.024 0.024 ↑ 20.0 5 1

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

31.          

CTE run_dates

32. 259.452 259.452 ↑ 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.107..259.452 rows=51,849 loops=1)

33. 41,019.059 185,355.419 ↑ 1,214.5 954,697 1

Sort (cost=519,086,894.53..521,985,525.19 rows=1,159,452,262 width=333) (actual time=182,719.137..185,355.419 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: 179792kB
34. 7,356.105 144,336.360 ↑ 1,214.5 954,697 1

Merge Left Join (cost=230,951,741.01..242,621,756.27 rows=1,159,452,262 width=333) (actual time=1,948.288..144,336.360 rows=954,697 loops=1)

  • Merge Cond: ((rim.run_id = log.run_id) AND (r.date = log.date) AND (s.stage = log.state))
35. 776.048 2,109.481 ↑ 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=1,948.273..2,109.481 rows=148,875 loops=1)

  • Sort Key: rim.run_id, r.date, s.stage
  • Sort Method: quicksort Memory: 27198kB
36. 283.815 1,333.433 ↑ 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=691.308..1,333.433 rows=148,875 loops=1)

  • Hash Cond: (r.run_id = rim.run_id)
37. 363.496 363.496 ↑ 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.112..363.496 rows=51,849 loops=1)

38. 133.364 686.122 ↑ 12.8 90,690 1

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

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

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

40. 0.042 0.042 ↑ 20.0 5 1

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

41. 92.244 428.715 ↓ 1.6 18,138 5

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

42. 88.626 336.471 ↓ 1.6 18,138 1

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

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

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

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

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

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

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

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

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

47. 0.041 0.041 ↑ 1.0 47 1

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

48. 20.353 20.353 ↑ 1.6 6,352 1

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

49. 2.053 2.099 ↓ 121.2 5,696 1

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

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

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

51. 65.289 129.346 ↑ 2.5 24,224 1

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

  • Sort Key: rim.blueprint_id
  • Sort Method: quicksort Memory: 3049kB
52. 64.057 64.057 ↑ 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.046..64.057 rows=29,195 loops=1)

53. 8,526.071 134,870.774 ↓ 1.0 5,952,046 1

Materialize (cost=1,166,807.48..1,196,509.49 rows=5,940,402 width=229) (actual time=112,445.189..134,870.774 rows=5,952,046 loops=1)

54. 115,707.212 126,344.703 ↑ 1.0 5,940,402 1

Sort (cost=1,166,807.48..1,181,658.49 rows=5,940,402 width=229) (actual time=112,445.181..126,344.703 rows=5,940,402 loops=1)

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

Seq Scan on run_log log (cost=0.00..127,173.02 rows=5,940,402 width=229) (actual time=0.016..10,637.491 rows=5,940,402 loops=1)

56. 0.027 507.797 ↑ 6.2 32 1

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

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

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

Planning time : 18.537 ms
Execution time : 198,051.064 ms