explain.depesz.com

PostgreSQL's explain analyze made readable

Result: By53 : stage_status3

Settings
# exclusive inclusive rows x rows loops node
1. 139.984 153,260.993 ↑ 579,726.1 10 1

Hash Join (cost=459,747,967.62..584,447,058.40 rows=5,797,261 width=8) (actual time=153,218.559..153,260.993 rows=10 loops=1)

  • Hash Cond: ((rim.run_id = lrid.run_id) AND (r.date = lrid.run_date))
2.          

CTE latest_run_id_dates

3. 0.013 649.671 ↑ 100.0 2 1

HashAggregate (cost=1,882,595.83..1,882,597.83 rows=200 width=8) (actual time=649.669..649.671 rows=2 loops=1)

  • Group Key: r_1.date
4. 0.082 649.658 ↑ 3,360.0 4 1

HashAggregate (cost=1,882,259.83..1,882,394.23 rows=13,440 width=86) (actual time=649.627..649.658 rows=4 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. 0.593 649.576 ↑ 1,680.0 20 1

HashAggregate (cost=1,880,663.87..1,880,999.86 rows=33,599 width=118) (actual time=649.459..649.576 rows=20 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.017 0.017 ↑ 20.0 5 1

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

8.          

CTE run_dates

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

10. 0.495 648.983 ↑ 148.7 226 1

Nested Loop Left Join (cost=1,324.13..1,572,161.56 rows=33,599 width=118) (actual time=217.936..648.983 rows=226 loops=1)

  • Join Filter: (log_1.state = s_1.stage)
  • Rows Removed by Join Filter: 904
11. 0.028 647.708 ↑ 1,680.0 20 1

Nested Loop (cost=1,323.58..1,533,472.70 rows=33,599 width=118) (actual time=217.805..647.708 rows=20 loops=1)

12. 0.025 0.025 ↑ 20.0 5 1

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

13. 0.019 647.655 ↑ 84.0 4 5

Materialize (cost=1,323.58..1,533,051.54 rows=336 width=86) (actual time=43.557..129.531 rows=4 loops=5)

14. 0.195 647.636 ↑ 84.0 4 1

Hash Join (cost=1,323.58..1,533,049.86 rows=336 width=86) (actual time=217.782..647.636 rows=4 loops=1)

  • Hash Cond: (r_1.run_id = rim_1.run_id)
15. 452.691 452.691 ↑ 1,523.0 201 1

CTE Scan on run_dates r_1 (cost=0.00..1,530,575.00 rows=306,115 width=8) (actual time=1.857..452.691 rows=201 loops=1)

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

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

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
17. 0.123 194.564 ↓ 2.0 135 1

Nested Loop (cost=17.57..1,322.74 rows=67 width=82) (actual time=1.626..194.564 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.014..0.017 rows=1 loops=1)

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

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

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

21. 0.006 0.068 ↑ 3.5 4 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
22. 0.005 0.062 ↑ 3.5 4 1

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

23. 0.020 0.057 ↑ 3.5 4 1

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

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

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

25. 0.015 0.015 ↑ 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.014..0.015 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.015..0.020 rows=3 loops=1)

  • Index Cond: (level0top = 'VID_NESTLE_MASTER_1'::text)
27. 0.780 0.780 ↓ 56.0 56 20

Index Only Scan using run_log_pkey on run_log log_1 (cost=0.56..1.14 rows=1 width=14) (actual time=0.011..0.039 rows=56 loops=20)

  • Index Cond: ((date = r_1.date) AND (run_id = rim_1.run_id))
  • Heap Fetches: 0
28. 2,243.949 152,471.328 ↑ 7,791.8 148,805 1

GroupAggregate (cost=457,865,362.80..507,142,083.93 rows=1,159,452,262 width=118) (actual time=149,007.217..152,471.328 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.028 0.028 ↑ 20.0 5 1

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

31.          

CTE run_dates

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

33. 19,953.112 150,227.379 ↑ 1,214.5 954,697 1

Sort (cost=457,557,868.45..460,456,499.11 rows=1,159,452,262 width=118) (actual time=149,007.180..150,227.379 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: quicksort Memory: 170764kB
34. 5,706.289 130,274.267 ↑ 1,214.5 954,697 1

Merge Left Join (cost=230,580,465.01..242,235,720.19 rows=1,159,452,262 width=118) (actual time=1,785.970..130,274.267 rows=954,697 loops=1)

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

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

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

38. 220.799 741.262 ↑ 12.8 90,690 1

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

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

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

40. 0.045 0.045 ↑ 20.0 5 1

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

41. 52.649 349.985 ↓ 1.6 18,138 5

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

42. 48.767 297.336 ↓ 1.6 18,138 1

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

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

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

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

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

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

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

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

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

47. 0.044 0.044 ↑ 1.0 47 1

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

48. 12.163 12.163 ↑ 1.6 6,352 1

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

49. 1.898 1.952 ↓ 121.2 5,696 1

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

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

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

51. 70.916 167.963 ↑ 2.5 24,224 1

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

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

53. 60,582.054 122,635.501 ↓ 1.0 5,952,046 1

Sort (cost=795,531.48..810,382.49 rows=5,940,402 width=14) (actual time=117,702.583..122,635.501 rows=5,952,046 loops=1)

  • Sort Key: log.run_id, log.date, log.state
  • Sort Method: external sort Disk: 165744kB
54. 62,053.447 62,053.447 ↑ 1.0 5,940,402 1

Seq Scan on run_log log (cost=0.00..127,173.02 rows=5,940,402 width=14) (actual time=0.025..62,053.447 rows=5,940,402 loops=1)

55. 0.005 649.681 ↑ 100.0 2 1

Hash (cost=4.00..4.00 rows=200 width=8) (actual time=649.681..649.681 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
56. 649.676 649.676 ↑ 100.0 2 1

CTE Scan on latest_run_id_dates lrid (cost=0.00..4.00 rows=200 width=8) (actual time=649.671..649.676 rows=2 loops=1)

Planning time : 24.758 ms
Execution time : 153,342.747 ms