explain.depesz.com

PostgreSQL's explain analyze made readable

Result: BDoA

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 193.939 ↑ 4,889.3 40 1

Append (cost=1,144,955.36..1,153,815.50 rows=195,571 width=120) (actual time=112.584..193.939 rows=40 loops=1)

  • Planning time: 5.841 ms
  • Execution time: 195.211 ms
2.          

CTE picklist_0

3. 0.300 0.300 ↑ 1.0 6 1

Seq Scan on t233_opportunitystagenamepicklistdim (cost=0.00..46.54 rows=6 width=4) (actual time=0.005..0.300 rows=6 loops=1)

  • Filter: (correlated_value = ANY ('{"06 - Won, Deploy & Expand","6 - Won, Deploy & Expand","Closed - Won","06 - Won. Deploy & Expand",Won,"06 - Won, Deploy & Expand"}'::text[]))
  • Rows Removed by Filter: 1225
4.          

CTE picklist_1

5. 0.295 0.295 ↑ 1.0 7 1

Seq Scan on t233_opportunitystagenamepicklistdim t233_opportunitystagenamepicklistdim_1 (cost=0.00..48.08 rows=7 width=4) (actual time=0.008..0.295 rows=7 loops=1)

  • Filter: (correlated_value = ANY ('{"HPE Not Pursued",Lost,Close:Duplicate,"HP Not Pursued",Duplicate,Error,"Closed - Lost"}'::text[]))
  • Rows Removed by Filter: 1224
6.          

CTE picklist_4

7. 0.438 0.438 ↑ 1.0 13 1

Seq Scan on t233_opportunitystagenamepicklistdim t233_opportunitystagenamepicklistdim_2 (cost=0.00..57.31 rows=13 width=4) (actual time=0.009..0.438 rows=13 loops=1)

  • Filter: (correlated_value = ANY ('{"06 - Won, Deploy & Expand",Lost,"6 - Won, Deploy & Expand",Close:Duplicate,"HP Not Pursued","06 - Won, Deploy & Expand",Error,"HPE Not Pursued","Closed - Won","06 - Won. Deploy & Expand",Won,Duplicate,"Closed - Lost"}'::text[]))
  • Rows Removed by Filter: 1218
8.          

CTE ownercte

9. 0.649 9.591 ↑ 68.3 360 1

HashAggregate (cost=23,698.64..23,944.69 rows=24,605 width=4) (actual time=9.536..9.591 rows=360 loops=1)

  • Group Key: distinctclosedateowner.ownerid
10.          

CTE owners

11. 0.719 2.123 ↑ 2.0 935 1

Nested Loop Semi Join (cost=60.06..17,848.02 rows=1,861 width=4) (actual time=0.146..2.123 rows=935 loops=1)

12. 0.374 0.469 ↑ 2.0 935 1

Bitmap Heap Scan on t166_userrolehierarchy (cost=59.64..6,841.91 rows=1,861 width=8) (actual time=0.129..0.469 rows=935 loops=1)

  • Recheck Cond: ((c663_ancestor_role_id = 237423) AND (end_stamp = '32503680000000'::bigint))
  • Heap Blocks: exact=131
13. 0.095 0.095 ↑ 2.0 945 1

Bitmap Index Scan on ix_t166_userrolehierarchy_ancestor_end_start_timestamp (cost=0.00..59.17 rows=1,861 width=0) (actual time=0.095..0.095 rows=945 loops=1)

  • Index Cond: ((c663_ancestor_role_id = 237423) AND (end_stamp = '32503680000000'::bigint))
14. 0.935 0.935 ↑ 1.0 1 935

Index Scan using ix_t67_userroledim_sid_timestamp_partial on t67_userroledim (cost=0.42..5.90 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=935)

  • Index Cond: ((sid = t166_userrolehierarchy.c662_user_role_id) AND (end_stamp = '32503680000000'::bigint))
  • Filter: ((NOT deleted) AND (sid <> '-2'::integer))
15. 0.351 8.942 ↑ 19.6 4,093 1

Nested Loop (cost=42.30..5,650.54 rows=80,033 width=4) (actual time=2.610..8.942 rows=4,093 loops=1)

16. 0.337 2.687 ↓ 3.7 738 1

HashAggregate (cost=41.87..43.87 rows=200 width=4) (actual time=2.584..2.687 rows=738 loops=1)

  • Group Key: owners.c1
17. 2.350 2.350 ↑ 2.0 935 1

CTE Scan on owners (cost=0.00..37.22 rows=1,861 width=4) (actual time=0.148..2.350 rows=935 loops=1)

18. 5.904 5.904 ↑ 1.0 6 738

Index Only Scan using ix_distinctclosedateowner_owner_closedate on distinctclosedateowner (cost=0.43..27.97 rows=6 width=4) (actual time=0.004..0.008 rows=6 loops=738)

  • Index Cond: ((ownerid = owners.c1) AND (closedate <= 20190131) AND (closedate >= 20181101))
  • Heap Fetches: 4093
19.          

CTE bucketac

20. 1.196 114.057 ↑ 4,309.3 19 1

GroupAggregate (cost=411,350.01..415,239.12 rows=81,876 width=92) (actual time=112.563..114.057 rows=19 loops=1)

  • Group Key: t237_oppfact.c844_opp_forecastcategory, (CASE WHEN (t237_oppfact_1.sid IS NULL) THEN 'deleted'::text WHEN ((t237_oppfact_1.c836_opp_close_date < 20181101) OR (t237_oppfact_1.c836_opp_close_date > 20190131)) THEN 'slipped'::text WHEN (hashed SubPlan 6) THEN CASE WHEN (hashed SubPlan 7) THEN 'won'::text WHEN (hashed SubPlan 8) THEN 'lost'::text ELSE CASE WHEN (t234_opportunityforecastcategorypicklistdim_2.correlated_app_order = t234_opportunityforecastcategorypicklistdim_3.correlated_app_order) THEN 'unchanged'::text WHEN (t234_opportunityforecastcategorypicklistdim_2.correlated_app_order > t234_opportunityforecastcategorypicklistdim_3.correlated_app_order) THEN 'upgraded'::text ELSE 'downgraded'::text END END ELSE 'lostOwnership'::text END)
21. 1.677 112.861 ↑ 20.4 4,010 1

Sort (cost=410,796.11..411,000.80 rows=81,876 width=72) (actual time=112.549..112.861 rows=4,010 loops=1)

  • Sort Key: t237_oppfact.c844_opp_forecastcategory, (CASE WHEN (t237_oppfact_1.sid IS NULL) THEN 'deleted'::text WHEN ((t237_oppfact_1.c836_opp_close_date < 20181101) OR (t237_oppfact_1.c836_opp_close_date > 20190131)) THEN 'slipped'::text WHEN (hashed SubPlan 6) THEN CASE WHEN (hashed SubPlan 7) THEN 'won'::text WHEN (hashed SubPlan 8) THEN 'lost'::text ELSE CASE WHEN (t234_opportunityforecastcategorypicklistdim_2.correlated_app_order = t234_opportunityforecastcategorypicklistdim_3.correlated_app_order) THEN 'unchanged'::text WHEN (t234_opportunityforecastcategorypicklistdim_2.correlated_app_order > t234_opportunityforecastcategorypicklistdim_3.correlated_app_order) THEN 'upgraded'::text ELSE 'downgraded'::text END END ELSE 'lostOwnership'::text END)
  • Sort Method: quicksort Memory: 628kB
22. 9.599 111.184 ↑ 20.4 4,010 1

Hash Left Join (cost=5,389.66..400,754.55 rows=81,876 width=72) (actual time=58.504..111.184 rows=4,010 loops=1)

  • Hash Cond: ((t237_oppfact.c845_opp_currency_code = cur177_t0_r0.sid) AND (t237_oppfact.c836_opp_close_date = cur177_t0_r0.rate_date))
23. 2.480 54.145 ↑ 15.0 4,010 1

Nested Loop Left Join (cost=594.38..378,828.62 rows=60,175 width=64) (actual time=10.278..54.145 rows=4,010 loops=1)

24. 1.249 43.645 ↑ 11.0 4,010 1

Hash Left Join (cost=594.38..363,981.29 rows=44,226 width=60) (actual time=10.265..43.645 rows=4,010 loops=1)

  • Hash Cond: (t237_oppfact_1.c844_opp_forecastcategory = t234_opportunityforecastcategorypicklistdim_3.sid)
25. 0.702 42.391 ↑ 11.0 4,010 1

Nested Loop Left Join (cost=574.71..363,353.51 rows=44,226 width=60) (actual time=10.255..42.391 rows=4,010 loops=1)

26. 0.961 21.639 ↑ 11.0 4,010 1

Hash Left Join (cost=574.14..10,343.91 rows=44,226 width=28) (actual time=10.244..21.639 rows=4,010 loops=1)

  • Hash Cond: (t237_oppfact.c844_opp_forecastcategory = t234_opportunityforecastcategorypicklistdim_2.sid)
27. 0.760 20.669 ↑ 11.0 4,010 1

Nested Loop (cost=554.47..9,716.13 rows=44,226 width=24) (actual time=10.227..20.669 rows=4,010 loops=1)

28. 0.181 9.829 ↓ 1.8 360 1

HashAggregate (cost=553.61..555.61 rows=200 width=4) (actual time=9.752..9.829 rows=360 loops=1)

  • Group Key: ownercte_1.c1
29. 9.648 9.648 ↑ 68.3 360 1

CTE Scan on ownercte ownercte_1 (cost=0.00..492.10 rows=24,605 width=4) (actual time=9.536..9.648 rows=360 loops=1)

30. 9.641 10.080 ↓ 2.2 11 360

Index Scan using ix_t237_oppfact_owner_closedate_timestamp on t237_oppfact (cost=0.86..45.75 rows=5 width=28) (actual time=0.011..0.028 rows=11 loops=360)

  • Index Cond: ((c832_opp_ownerid = ownercte_1.c1) AND (c836_opp_close_date >= 20181101) AND (c836_opp_close_date <= 20190131) AND (start_stamp <= '1541055600000'::bigint) AND (end_stamp > '1541055600000'::bigint))
  • Filter: ((NOT deleted) AND (NOT (hashed SubPlan 9)))
  • Rows Removed by Filter: 2
31.          

SubPlan (forIndex Scan)

32. 0.439 0.439 ↑ 1.0 13 1

CTE Scan on picklist_4 cte0_4 (cost=0.00..0.26 rows=13 width=4) (actual time=0.009..0.439 rows=13 loops=1)

33. 0.005 0.009 ↑ 86.0 5 1

Hash (cost=14.30..14.30 rows=430 width=8) (actual time=0.009..0.009 rows=5 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
34. 0.004 0.004 ↑ 86.0 5 1

Seq Scan on t234_opportunityforecastcategorypicklistdim t234_opportunityforecastcategorypicklistdim_2 (cost=0.00..14.30 rows=430 width=8) (actual time=0.003..0.004 rows=5 loops=1)

35. 20.050 20.050 ↑ 1.0 1 4,010

Index Scan using ix_t237_oppfact_sid_timestamp on t237_oppfact t237_oppfact_1 (cost=0.56..7.97 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=4,010)

  • Index Cond: ((t237_oppfact.sid = sid) AND (t237_oppfact.sid = sid) AND (start_stamp <= '1542009599999'::bigint) AND (end_stamp > '1542009599999'::bigint))
  • Filter: (NOT deleted)
36. 0.003 0.005 ↑ 86.0 5 1

Hash (cost=14.30..14.30 rows=430 width=8) (actual time=0.005..0.005 rows=5 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
37. 0.002 0.002 ↑ 86.0 5 1

Seq Scan on t234_opportunityforecastcategorypicklistdim t234_opportunityforecastcategorypicklistdim_3 (cost=0.00..14.30 rows=430 width=8) (actual time=0.001..0.002 rows=5 loops=1)

38. 0.000 8.020 ↑ 2.0 1 4,010

Append (cost=0.00..0.32 rows=2 width=16) (actual time=0.002..0.002 rows=1 loops=4,010)

39. 0.000 0.000 ↓ 0.0 0 4,010

Seq Scan on clari_conversion_rate cur177_t1_r1 (cost=0.00..0.00 rows=1 width=16) (actual time=0.000..0.000 rows=0 loops=4,010)

  • Filter: ((to_iso_code = 'USD'::text) AND (t237_oppfact_1.c845_opp_currency_code = sid) AND (t237_oppfact_1.c836_opp_close_date = rate_date))
40. 8.020 8.020 ↑ 1.0 1 4,010

Index Scan using ix_usd_clari_conversion_rate_date_isocode on usd_clari_conversion_rate cur177_t1_r1_1 (cost=0.29..0.32 rows=1 width=16) (actual time=0.002..0.002 rows=1 loops=4,010)

  • Index Cond: ((t237_oppfact_1.c836_opp_close_date = rate_date) AND (t237_oppfact_1.c845_opp_currency_code = sid))
  • Filter: (to_iso_code = 'USD'::text)
41. 18.945 46.812 ↑ 1.0 101,598 1

Hash (cost=2,220.16..2,220.16 rows=101,614 width=16) (actual time=46.812..46.812 rows=101,598 loops=1)

  • Buckets: 131072 Batches: 2 Memory Usage: 3409kB
42. 6.082 27.867 ↑ 1.0 101,598 1

Append (cost=0.00..2,220.16 rows=101,614 width=16) (actual time=0.115..27.867 rows=101,598 loops=1)

43. 0.001 0.001 ↓ 0.0 0 1

Seq Scan on clari_conversion_rate cur177_t0_r0 (cost=0.00..0.00 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=1)

  • Filter: (to_iso_code = 'USD'::text)
44. 21.784 21.784 ↑ 1.0 101,598 1

Seq Scan on usd_clari_conversion_rate cur177_t0_r0_1 (cost=0.00..2,220.16 rows=101,613 width=16) (actual time=0.114..21.784 rows=101,598 loops=1)

  • Filter: (to_iso_code = 'USD'::text)
45.          

SubPlan (forHash Left Join)

46. 0.024 0.024 ↑ 68.3 360 1

CTE Scan on ownercte (cost=0.00..492.10 rows=24,605 width=4) (actual time=0.001..0.024 rows=360 loops=1)

47. 0.305 0.305 ↑ 1.0 6 1

CTE Scan on picklist_0 cte0_2 (cost=0.00..0.12 rows=6 width=4) (actual time=0.007..0.305 rows=6 loops=1)

48. 0.299 0.299 ↑ 1.0 7 1

CTE Scan on picklist_1 cte0_3 (cost=0.00..0.14 rows=7 width=4) (actual time=0.008..0.299 rows=7 loops=1)

49.          

CTE bucketec

50. 0.132 79.810 ↑ 5,414.0 21 1

GroupAggregate (cost=700,767.89..705,599.93 rows=113,695 width=116) (actual time=79.655..79.810 rows=21 loops=1)

  • Group Key: (CASE WHEN (t237_oppfact_3.sid IS NULL) THEN 'newBucket'::text WHEN (NOT (hashed SubPlan 11)) THEN CASE WHEN (t237_oppfact_3.c836_opp_close_date > 20190131) THEN 'pulledInBucket'::text WHEN (t237_oppfact_3.c836_opp_close_date < 20181101) THEN 'pushedInBucket'::text WHEN (hashed SubPlan 12) THEN 'otherBucket'::text ELSE 'gainedOwnershipBucket'::text END ELSE 'otherBucket'::text END), (CASE WHEN (hashed SubPlan 13) THEN 'won'::text WHEN (hashed SubPlan 14) THEN 'lost'::text ELSE 'newOpen'::text END), t237_oppfact_2.c844_opp_forecastcategory
51. 0.274 79.678 ↑ 282.8 402 1

Sort (cost=700,213.70..700,497.93 rows=113,695 width=88) (actual time=79.641..79.678 rows=402 loops=1)

  • Sort Key: (CASE WHEN (t237_oppfact_3.sid IS NULL) THEN 'newBucket'::text WHEN (NOT (hashed SubPlan 11)) THEN CASE WHEN (t237_oppfact_3.c836_opp_close_date > 20190131) THEN 'pulledInBucket'::text WHEN (t237_oppfact_3.c836_opp_close_date < 20181101) THEN 'pushedInBucket'::text WHEN (hashed SubPlan 12) THEN 'otherBucket'::text ELSE 'gainedOwnershipBucket'::text END ELSE 'otherBucket'::text END), (CASE WHEN (hashed SubPlan 13) THEN 'won'::text WHEN (hashed SubPlan 14) THEN 'lost'::text ELSE 'newOpen'::text END), t237_oppfact_2.c844_opp_forecastcategory
  • Sort Method: quicksort Memory: 58kB
52. 5.068 79.404 ↑ 282.8 402 1

Hash Left Join (cost=5,903.93..685,223.77 rows=113,695 width=88) (actual time=47.405..79.404 rows=402 loops=1)

  • Hash Cond: ((t237_oppfact_2.c845_opp_currency_code = cur177_t0_r0_2.sid) AND (t237_oppfact_2.c836_opp_close_date = cur177_t0_r0_2.rate_date))
53. 0.864 27.726 ↑ 207.9 402 1

Nested Loop Left Join (cost=1,108.36..657,444.30 rows=83,561 width=44) (actual time=0.283..27.726 rows=402 loops=1)

  • Filter: ((t237_oppfact_3.sid IS NULL) OR (t237_oppfact_3.c836_opp_close_date < 20181101) OR (t237_oppfact_3.c836_opp_close_date > 20190131) OR (NOT (hashed SubPlan 15)))
  • Rows Removed by Filter: 4431
54. 1.221 7.503 ↑ 17.8 4,833 1

Nested Loop (cost=554.18..9,662.63 rows=86,108 width=28) (actual time=0.112..7.503 rows=4,833 loops=1)

55. 0.136 0.162 ↓ 1.8 360 1

HashAggregate (cost=553.61..555.61 rows=200 width=4) (actual time=0.097..0.162 rows=360 loops=1)

  • Group Key: ownercte_4.c1
56. 0.026 0.026 ↑ 68.3 360 1

CTE Scan on ownercte ownercte_4 (cost=0.00..492.10 rows=24,605 width=4) (actual time=0.000..0.026 rows=360 loops=1)

57. 6.120 6.120 ↓ 1.3 13 360

Index Scan using ix_t237_oppfact_owner_closedate_timestamp on t237_oppfact t237_oppfact_2 (cost=0.56..45.44 rows=10 width=32) (actual time=0.006..0.017 rows=13 loops=360)

  • Index Cond: ((c832_opp_ownerid = ownercte_4.c1) AND (c836_opp_close_date >= 20181101) AND (c836_opp_close_date <= 20190131) AND (start_stamp <= '1542009599999'::bigint) AND (end_stamp > '1542009599999'::bigint))
  • Filter: (NOT deleted)
  • Rows Removed by Filter: 0
58. 19.332 19.332 ↑ 1.0 1 4,833

Index Scan using ix_t237_oppfact_sid_timestamp on t237_oppfact t237_oppfact_3 (cost=0.56..7.50 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=4,833)

  • Index Cond: ((t237_oppfact_2.sid = sid) AND (t237_oppfact_2.sid = sid) AND (start_stamp <= '1541055600000'::bigint) AND (end_stamp > '1541055600000'::bigint))
  • Filter: (NOT deleted)
59.          

SubPlan (forNested Loop Left Join)

60. 0.027 0.027 ↑ 68.3 360 1

CTE Scan on ownercte ownercte_3 (cost=0.00..492.10 rows=24,605 width=4) (actual time=0.001..0.027 rows=360 loops=1)

61. 18.952 46.579 ↑ 1.0 101,598 1

Hash (cost=2,220.16..2,220.16 rows=101,614 width=16) (actual time=46.579..46.579 rows=101,598 loops=1)

  • Buckets: 131072 Batches: 2 Memory Usage: 3409kB
62. 6.765 27.627 ↑ 1.0 101,598 1

Append (cost=0.00..2,220.16 rows=101,614 width=16) (actual time=0.059..27.627 rows=101,598 loops=1)

63. 0.001 0.001 ↓ 0.0 0 1

Seq Scan on clari_conversion_rate cur177_t0_r0_2 (cost=0.00..0.00 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=1)

  • Filter: (to_iso_code = 'USD'::text)
64. 20.861 20.861 ↑ 1.0 101,598 1

Seq Scan on usd_clari_conversion_rate cur177_t0_r0_3 (cost=0.00..2,220.16 rows=101,613 width=16) (actual time=0.058..20.861 rows=101,598 loops=1)

  • Filter: (to_iso_code = 'USD'::text)
65.          

SubPlan (forHash Left Join)

66. 0.004 0.004 ↑ 1.0 13 1

CTE Scan on picklist_4 cte0_5 (cost=0.00..0.26 rows=13 width=4) (actual time=0.001..0.004 rows=13 loops=1)

67. 0.025 0.025 ↑ 68.3 360 1

CTE Scan on ownercte ownercte_2 (cost=0.00..492.10 rows=24,605 width=4) (actual time=0.000..0.025 rows=360 loops=1)

68. 0.002 0.002 ↑ 1.0 6 1

CTE Scan on picklist_0 cte0_6 (cost=0.00..0.12 rows=6 width=4) (actual time=0.000..0.002 rows=6 loops=1)

69. 0.000 0.000 ↑ 1.0 7 1

CTE Scan on picklist_1 cte0_7 (cost=0.00..0.14 rows=7 width=4) (actual time=0.000..0.000 rows=7 loops=1)

70. 0.016 114.089 ↑ 4,309.3 19 1

Hash Join (cost=19.68..2,782.99 rows=81,876 width=120) (actual time=112.584..114.089 rows=19 loops=1)

  • Hash Cond: (cte0.c4 = t234_opportunityforecastcategorypicklistdim.sid)
71. 114.065 114.065 ↑ 4,309.3 19 1

CTE Scan on bucketac cte0 (cost=0.00..1,637.52 rows=81,876 width=92) (actual time=112.566..114.065 rows=19 loops=1)

72. 0.003 0.008 ↑ 86.0 5 1

Hash (cost=14.30..14.30 rows=430 width=36) (actual time=0.008..0.008 rows=5 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
73. 0.005 0.005 ↑ 86.0 5 1

Seq Scan on t234_opportunityforecastcategorypicklistdim (cost=0.00..14.30 rows=430 width=36) (actual time=0.005..0.005 rows=5 loops=1)

74. 0.009 79.850 ↑ 5,414.0 21 1

Subquery Scan on *SELECT* 2 (cost=19.68..5,278.07 rows=113,695 width=120) (actual time=79.678..79.850 rows=21 loops=1)

75. 0.013 79.841 ↑ 5,414.0 21 1

Hash Join (cost=19.68..3,856.88 rows=113,695 width=144) (actual time=79.674..79.841 rows=21 loops=1)

  • Hash Cond: (cte0_1.c6 = t234_opportunityforecastcategorypicklistdim_1.sid)
76. 79.820 79.820 ↑ 5,414.0 21 1

CTE Scan on bucketec cte0_1 (cost=0.00..2,273.90 rows=113,695 width=116) (actual time=79.657..79.820 rows=21 loops=1)

77. 0.003 0.008 ↑ 86.0 5 1

Hash (cost=14.30..14.30 rows=430 width=36) (actual time=0.008..0.008 rows=5 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
78. 0.005 0.005 ↑ 86.0 5 1

Seq Scan on t234_opportunityforecastcategorypicklistdim t234_opportunityforecastcategorypicklistdim_1 (cost=0.00..14.30 rows=430 width=36) (actual time=0.004..0.005 rows=5 loops=1)