explain.depesz.com

PostgreSQL's explain analyze made readable

Result: rRtN

Settings
# exclusive inclusive rows x rows loops node
1. 6.920 8,787.449 ↑ 1.1 595 1

Group (cost=11,823.33..911,975.03 rows=659 width=248) (actual time=1,302.560..8,787.449 rows=595 loops=1)

  • Group Key: dates.my_date, o.id, sbp.id, sbp_baseline.id, sbic.id, sbi.id, sbichanges.id, sbichanges_user.id
2.          

CTE dates

3. 0.002 0.002 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1)

4.          

CTE relevant_issues

5. 85.462 1,259.616 ↑ 40.3 239 1

GroupAggregate (cost=9,742.90..9,911.53 rows=9,636 width=16) (actual time=1,135.792..1,259.616 rows=239 loops=1)

  • Group Key: sbitems.id
6. 162.367 1,174.154 ↓ 29.4 283,436 1

Sort (cost=9,742.90..9,766.99 rows=9,636 width=16) (actual time=1,135.352..1,174.154 rows=283,436 loops=1)

  • Sort Key: sbitems.id
  • Sort Method: external merge Disk: 7,224kB
7. 62.620 1,011.787 ↓ 29.4 283,436 1

Hash Join (cost=1,965.57..9,105.27 rows=9,636 width=16) (actual time=29.185..1,011.787 rows=283,436 loops=1)

  • Hash Cond: (sbi_1.item_id = sbitems.id)
8. 77.146 927.335 ↓ 29.4 283,436 1

Hash Join (cost=395.51..7,509.90 rows=9,636 width=16) (actual time=7.154..927.335 rows=283,436 loops=1)

  • Hash Cond: (sba.device_id = d.id)
  • Join Filter: ((d.archived_at IS NULL) OR (d.archived_at > dates_1.my_date))
  • Rows Removed by Join Filter: 62,449
9. 84.206 846.511 ↓ 31.2 345,885 1

Hash Join (cost=163.05..7,248.31 rows=11,074 width=24) (actual time=1.969..846.511 rows=345,885 loops=1)

  • Hash Cond: (sbi_1.assignment_id = sba.id)
  • Join Filter: ((sba.archived_at IS NULL) OR (sba.archived_at > dates_1.my_date))
10. 53.161 760.417 ↓ 8.0 359,963 1

Nested Loop (cost=0.42..6,967.67 rows=44,927 width=24) (actual time=0.055..760.417 rows=359,963 loops=1)

11. 0.001 0.001 ↑ 1.0 1 1

CTE Scan on dates dates_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.000..0.001 rows=1 loops=1)

12. 707.255 707.255 ↓ 8.0 359,963 1

Index Scan using scap_benchmark_issues_created_at_idx on scap_benchmark_issues sbi_1 (cost=0.42..6,518.38 rows=44,927 width=32) (actual time=0.053..707.255 rows=359,963 loops=1)

  • Index Cond: ((created_at <= dates_1.my_date) AND (created_at <= dates_1.my_date))
  • Filter: ((organization_id = 1) AND ((resolved_at IS NULL) OR (resolved_at > dates_1.my_date)))
  • Rows Removed by Filter: 134,927
13. 0.379 1.888 ↑ 1.0 1,749 1

Hash (cost=140.76..140.76 rows=1,749 width=24) (actual time=1.888..1.888 rows=1,749 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 98kB
14. 1.509 1.509 ↑ 1.0 1,749 1

Seq Scan on scap_benchmark_assignments sba (cost=0.00..140.76 rows=1,749 width=24) (actual time=0.006..1.509 rows=1,749 loops=1)

  • Filter: (profile_id = 46)
  • Rows Removed by Filter: 3,912
15. 0.882 3.678 ↑ 1.0 1,976 1

Hash (cost=207.76..207.76 rows=1,976 width=16) (actual time=3.678..3.678 rows=1,976 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 97kB
16. 2.796 2.796 ↑ 1.0 1,976 1

Seq Scan on devices d (cost=0.00..207.76 rows=1,976 width=16) (actual time=0.021..2.796 rows=1,976 loops=1)

17. 4.581 21.832 ↑ 1.0 10,625 1

Hash (cost=1,437.25..1,437.25 rows=10,625 width=8) (actual time=21.832..21.832 rows=10,625 loops=1)

  • Buckets: 16,384 Batches: 1 Memory Usage: 544kB
18. 17.251 17.251 ↑ 1.0 10,625 1

Seq Scan on scap_benchmark_items sbitems (cost=0.00..1,437.25 rows=10,625 width=8) (actual time=0.006..17.251 rows=10,625 loops=1)

19. 1.146 16.179 ↑ 1.1 595 1

Sort (cost=1,911.80..1,913.45 rows=659 width=215) (actual time=15.722..16.179 rows=595 loops=1)

  • Sort Key: dates.my_date, sbp_baseline.id, sbic.id, sbi.id, sbichanges.id, sbichanges_user.id
  • Sort Method: quicksort Memory: 144kB
20. 0.167 15.033 ↑ 1.1 595 1

Hash Left Join (cost=339.30..1,880.94 rows=659 width=215) (actual time=5.965..15.033 rows=595 loops=1)

  • Hash Cond: (sbichanges.created_by_id = sbichanges_user.id)
21. 0.056 14.842 ↑ 1.1 595 1

Hash Left Join (cost=338.12..1,877.54 rows=659 width=179) (actual time=5.929..14.842 rows=595 loops=1)

  • Hash Cond: ((SubPlan 10) = sbichanges.id)
22. 0.490 12.167 ↑ 1.1 595 1

Hash Left Join (cost=336.78..1,828.05 rows=659 width=127) (actual time=5.647..12.167 rows=595 loops=1)

  • Hash Cond: ((SubPlan 8) = sbic.id)
23. 0.272 4.740 ↑ 1.1 595 1

Hash Left Join (cost=66.76..1,282.08 rows=659 width=111) (actual time=1.466..4.740 rows=595 loops=1)

  • Hash Cond: ((sbp.id = sbip.profile_id) AND (sbi.id = sbip.item_id))
  • Filter: ((sbi.type = 8,192) OR (sbip.selected AND (sbi.weight > '0'::double precision)))
  • Rows Removed by Filter: 111
24. 0.133 4.174 ↑ 1.0 706 1

Nested Loop (cost=42.38..1,237.53 rows=723 width=119) (actual time=1.160..4.174 rows=706 loops=1)

25. 0.019 1.020 ↑ 1.0 1 1

Hash Left Join (cost=16.48..34.38 rows=1 width=40) (actual time=1.015..1.020 rows=1 loops=1)

  • Hash Cond: ((SubPlan 9) = sbp_baseline.id)
26. 0.002 0.397 ↑ 1.0 1 1

Nested Loop (cost=0.29..17.39 rows=1 width=32) (actual time=0.393..0.397 rows=1 loops=1)

27. 0.001 0.138 ↑ 1.0 1 1

Nested Loop (cost=0.14..9.22 rows=1 width=32) (actual time=0.136..0.138 rows=1 loops=1)

28. 0.006 0.030 ↑ 1.0 1 1

Nested Loop (cost=0.00..1.04 rows=1 width=16) (actual time=0.028..0.030 rows=1 loops=1)

29. 0.004 0.004 ↑ 1.0 1 1

CTE Scan on dates (cost=0.00..0.02 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=1)

30. 0.020 0.020 ↑ 1.0 1 1

Seq Scan on organizations o (cost=0.00..1.01 rows=1 width=8) (actual time=0.019..0.020 rows=1 loops=1)

  • Filter: (id = 1)
31. 0.107 0.107 ↑ 1.0 1 1

Index Scan using scap_profiles_pkey on scap_profiles sbp (cost=0.14..8.16 rows=1 width=16) (actual time=0.106..0.107 rows=1 loops=1)

  • Index Cond: (id = 46)
  • Filter: ((NOT archived) AND (parent_id IS NULL) AND (benchmark_id = 24))
32. 0.257 0.257 ↑ 1.0 1 1

Index Only Scan using scap_benchmarks_pkey on scap_benchmarks sb (cost=0.14..8.16 rows=1 width=8) (actual time=0.256..0.257 rows=1 loops=1)

  • Index Cond: (id = 24)
  • Heap Fetches: 1
33. 0.018 0.550 ↑ 1.0 142 1

Hash (cost=14.42..14.42 rows=142 width=8) (actual time=0.550..0.550 rows=142 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 14kB
34. 0.532 0.532 ↑ 1.0 142 1

Seq Scan on scap_profiles sbp_baseline (cost=0.00..14.42 rows=142 width=8) (actual time=0.214..0.532 rows=142 loops=1)

35.          

SubPlan (for Hash Left Join)

36. 0.002 0.054 ↑ 1.0 1 2

Limit (cost=15.85..15.86 rows=1 width=8) (actual time=0.027..0.027 rows=1 loops=2)

37. 0.008 0.052 ↑ 1.0 1 2

Sort (cost=15.85..15.86 rows=1 width=8) (actual time=0.026..0.026 rows=1 loops=2)

  • Sort Key: scap_profiles.id DESC
  • Sort Method: quicksort Memory: 25kB
38. 0.044 0.044 ↑ 1.0 1 2

Seq Scan on scap_profiles (cost=0.00..15.84 rows=1 width=8) (actual time=0.019..0.022 rows=1 loops=2)

  • Filter: ((created_at <= dates.my_date) AND ((archived_at IS NULL) OR (archived_at > dates.my_date)) AND (parent_id = sbp.id) AND (organization_id = o.id))
  • Rows Removed by Filter: 141
39. 2.907 3.021 ↑ 1.0 706 1

Bitmap Heap Scan on scap_benchmark_items sbi (cost=25.90..1,195.93 rows=723 width=95) (actual time=0.142..3.021 rows=706 loops=1)

  • Recheck Cond: (benchmark_id = 24)
  • Filter: (NOT archived)
  • Rows Removed by Filter: 19
  • Heap Blocks: exact=175
40. 0.114 0.114 ↑ 1.0 725 1

Bitmap Index Scan on scap_benchmark_items_benchmark_id_uid_idx (cost=0.00..25.72 rows=725 width=0) (actual time=0.113..0.114 rows=725 loops=1)

  • Index Cond: (benchmark_id = 24)
41. 0.048 0.294 ↑ 1.0 286 1

Hash (cost=20.09..20.09 rows=286 width=17) (actual time=0.294..0.294 rows=286 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 22kB
42. 0.246 0.246 ↑ 1.0 286 1

Index Scan using scap_benchmark_items_profiles_profile_id_idx on scap_benchmark_items_profiles sbip (cost=0.29..20.09 rows=286 width=17) (actual time=0.047..0.246 rows=286 loops=1)

  • Index Cond: (profile_id = 46)
43. 1.309 3.485 ↑ 1.0 8,223 1

Hash (cost=167.23..167.23 rows=8,223 width=16) (actual time=3.485..3.485 rows=8,223 loops=1)

  • Buckets: 16,384 Batches: 1 Memory Usage: 514kB
44. 2.176 2.176 ↑ 1.0 8,223 1

Seq Scan on scap_benchmark_item_configs sbic (cost=0.00..167.23 rows=8,223 width=16) (actual time=0.018..2.176 rows=8,223 loops=1)

45.          

SubPlan (for Hash Left Join)

46. 0.863 3.452 ↑ 1.0 1 863

Limit (cost=8.32..8.32 rows=1 width=12) (actual time=0.004..0.004 rows=1 loops=863)

47. 0.863 2.589 ↑ 1.0 1 863

Sort (cost=8.32..8.32 rows=1 width=12) (actual time=0.003..0.003 rows=1 loops=863)

  • Sort Key: scap_benchmark_item_configs.priority DESC
  • Sort Method: quicksort Memory: 25kB
48. 1.726 1.726 ↑ 1.0 1 863

Index Scan using scap_benchmark_item_configs_item_id_organization_id_profil_idx1 on scap_benchmark_item_configs (cost=0.29..8.31 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=863)

  • Index Cond: (item_id = sbi.id)
  • Filter: (((organization_id IS NULL) OR (organization_id = o.id)) AND ((profile_id IS NULL) OR (profile_id = sbp.id)))
49. 0.007 0.227 ↑ 1.0 15 1

Hash (cost=1.15..1.15 rows=15 width=52) (actual time=0.227..0.227 rows=15 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
50. 0.220 0.220 ↑ 1.0 15 1

Seq Scan on scap_benchmark_item_changes sbichanges (cost=0.00..1.15 rows=15 width=52) (actual time=0.218..0.220 rows=15 loops=1)

51.          

SubPlan (for Hash Left Join)

52. 0.598 2.392 ↓ 0.0 0 598

Limit (cost=1.35..1.35 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=598)

53. 0.598 1.794 ↓ 0.0 0 598

Sort (cost=1.35..1.35 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=598)

  • Sort Key: scap_benchmark_item_changes.id DESC
  • Sort Method: quicksort Memory: 25kB
54. 1.196 1.196 ↓ 0.0 0 598

Seq Scan on scap_benchmark_item_changes (cost=0.00..1.34 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=598)

  • Filter: ((NOT in_baseline) AND (created_at <= dates.my_date) AND (comment <> ''::text) AND (item_id = sbi.id) AND (profile_id = sbp.id) AND (organization_id = o.id))
  • Rows Removed by Filter: 15
55. 0.003 0.024 ↑ 1.0 8 1

Hash (cost=1.08..1.08 rows=8 width=40) (actual time=0.024..0.024 rows=8 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
56. 0.021 0.021 ↑ 1.0 8 1

Seq Scan on users sbichanges_user (cost=0.00..1.08 rows=8 width=40) (actual time=0.020..0.021 rows=8 loops=1)

57.          

SubPlan (for Group)

58. 0.595 1,272.110 ↑ 1.0 1 595

Aggregate (cost=216.93..216.94 rows=1 width=8) (actual time=2.138..2.138 rows=1 loops=595)

59. 1,271.515 1,271.515 ↓ 0.0 0 595

CTE Scan on relevant_issues (cost=0.00..216.81 rows=48 width=8) (actual time=2.134..2.137 rows=0 loops=595)

  • Filter: (item_id = sbi.id)
  • Rows Removed by Filter: 239
60. 7.140 7.140 ↓ 0.0 0 595

Index Scan using scap_benchmark_items_profiles_item_id_idx on scap_benchmark_items_profiles (cost=0.29..9.42 rows=1 width=1) (actual time=0.012..0.012 rows=0 loops=595)

  • Index Cond: (item_id = sbi.id)
  • Filter: (selected AND (profile_id = sbp_baseline.id))
  • Rows Removed by Filter: 2
61. 11.900 135.660 ↑ 1.0 1 595

Aggregate (cost=291.40..291.41 rows=1 width=8) (actual time=0.228..0.228 rows=1 loops=595)

62. 12.444 123.760 ↓ 3.5 138 595

Nested Loop (cost=17.67..291.31 rows=39 width=8) (actual time=0.060..0.208 rows=138 loops=595)

63. 2.380 2.380 ↓ 0.0 0 595

Index Scan using scap_benchmark_breaches_item_id_idx on scap_benchmark_breaches sbb (cost=0.15..8.17 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=595)

  • Index Cond: (item_id = sbi.id)
  • Filter: ((NOT resolved) AND (organization_id = o.id))
  • Rows Removed by Filter: 0
64. 84.240 108.936 ↓ 15.6 1,142 72

Bitmap Heap Scan on scap_benchmark_breach_items sbbi (cost=17.53..282.41 rows=73 width=8) (actual time=0.453..1.513 rows=1,142 loops=72)

  • Recheck Cond: ((breach_id = sbb.id) AND (profile_id = sbp.id) AND (NOT resolved))
  • Heap Blocks: exact=63,747
65. 24.696 24.696 ↓ 15.6 1,142 72

Bitmap Index Scan on scap_benchmark_breach_items_breach_id_device_id_profile_id_idx (cost=0.00..17.51 rows=73 width=0) (actual time=0.343..0.343 rows=1,142 loops=72)

  • Index Cond: ((breach_id = sbb.id) AND (profile_id = sbp.id))
66. 1.785 5.950 ↑ 1.0 1 595

Aggregate (cost=682.65..682.66 rows=1 width=8) (actual time=0.010..0.010 rows=1 loops=595)

67. 1.008 4.165 ↑ 19.9 9 595

Nested Loop (cost=0.57..682.20 rows=179 width=8) (actual time=0.002..0.007 rows=9 loops=595)

68. 0.595 0.595 ↓ 0.0 0 595

Index Scan using scap_benchmark_breaches_item_id_idx on scap_benchmark_breaches sbincidents (cost=0.15..8.18 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=595)

  • Index Cond: (item_id = sbi.id)
  • Filter: ((created_at <= dates.my_date) AND (organization_id = o.id) AND (created_at >= (dates.my_date - '90 days'::interval)))
  • Rows Removed by Filter: 0
69. 2.562 2.562 ↓ 2.6 860 6

Index Only Scan using scap_benchmark_breach_items_profile_id_breach_id_idx on scap_benchmark_breach_items sbincitems (cost=0.42..670.66 rows=336 width=8) (actual time=0.065..0.427 rows=860 loops=6)

  • Index Cond: ((profile_id = sbp.id) AND (breach_id = sbincidents.id))
  • Heap Fetches: 5,160
70. 58.310 7,343.490 ↑ 1.0 1 595

Aggregate (cost=165.47..165.48 rows=1 width=8) (actual time=12.342..12.342 rows=1 loops=595)

71. 160.650 7,285.180 ↓ 21.3 383 595

Bitmap Heap Scan on scap_benchmark_changes sbc (cost=97.13..165.43 rows=18 width=8) (actual time=11.991..12.244 rows=383 loops=595)

  • Recheck Cond: ((created_at >= (dates.my_date - '90 days'::interval)) AND (created_at <= dates.my_date) AND (item_id = sbi.id))
  • Filter: (organization_id = o.id)
  • Heap Blocks: exact=26,554
72. 55.930 7,124.530 ↓ 0.0 0 595

BitmapAnd (cost=97.13..97.13 rows=18 width=0) (actual time=11.974..11.974 rows=0 loops=595)

73. 7,036.470 7,036.470 ↓ 166.6 228,041 595

Bitmap Index Scan on scap_benchmark_changes_created_at_idx (cost=0.00..30.12 rows=1,369 width=0) (actual time=11.826..11.826 rows=228,041 loops=595)

  • Index Cond: ((created_at >= (dates.my_date - '90 days'::interval)) AND (created_at <= dates.my_date))
74. 32.130 32.130 ↑ 7.6 459 595

Bitmap Index Scan on scap_benchmark_changes_item_id_idx (cost=0.00..66.75 rows=3,511 width=0) (actual time=0.054..0.054 rows=459 loops=595)

  • Index Cond: (item_id = sbi.id)
Planning time : 33.724 ms
Execution time : 8,811.046 ms