explain.depesz.com

PostgreSQL's explain analyze made readable

Result: lSDl

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Append (cost=1,249,971.38..1,328,931.86 rows=23 width=44) (actual rows= loops=)

2.          

CTE con

3. 0.000 0.000 ↓ 0.0

Seq Scan on contracts (cost=0.00..28.93 rows=631 width=36) (actual rows= loops=)

4.          

CTE act

5. 0.000 0.000 ↓ 0.0

Subquery Scan on t (cost=17.92..20.20 rows=1 width=44) (actual rows= loops=)

  • Filter: (t.rn = 1)
6. 0.000 0.000 ↓ 0.0

WindowAgg (cost=17.92..19.32 rows=70 width=44) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Sort (cost=17.92..18.10 rows=70 width=36) (actual rows= loops=)

  • Sort Key: con.company_id, con.e DESC
8. 0.000 0.000 ↓ 0.0

CTE Scan on con (cost=0.00..15.78 rows=70 width=36) (actual rows= loops=)

  • Filter: (('2020-08-01 00:00:00'::timestamp without time zone >= s) AND ('2020-08-01 00:00:00'::timestamp without time zone <= e))
9.          

CTE past

10. 0.000 0.000 ↓ 0.0

Subquery Scan on t_1 (cost=22.30..29.12 rows=1 width=44) (actual rows= loops=)

  • Filter: (t_1.rn = 1)
11. 0.000 0.000 ↓ 0.0

WindowAgg (cost=22.30..26.50 rows=210 width=44) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Sort (cost=22.30..22.82 rows=210 width=36) (actual rows= loops=)

  • Sort Key: con_1.company_id, con_1.e DESC
13. 0.000 0.000 ↓ 0.0

CTE Scan on con con_1 (cost=0.00..14.20 rows=210 width=36) (actual rows= loops=)

  • Filter: ('2020-08-01 00:00:00'::timestamp without time zone > e)
14.          

CTE fut

15. 0.000 0.000 ↓ 0.0

Subquery Scan on t_2 (cost=22.30..29.12 rows=1 width=44) (actual rows= loops=)

  • Filter: (t_2.rn = 1)
16. 0.000 0.000 ↓ 0.0

WindowAgg (cost=22.30..26.50 rows=210 width=44) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Sort (cost=22.30..22.82 rows=210 width=36) (actual rows= loops=)

  • Sort Key: con_2.company_id, con_2.s
18. 0.000 0.000 ↓ 0.0

CTE Scan on con con_2 (cost=0.00..14.20 rows=210 width=36) (actual rows= loops=)

  • Filter: ('2020-08-01 00:00:00'::timestamp without time zone < s)
19.          

CTE co

20. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.00..0.12 rows=1 width=36) (actual rows= loops=)

  • Join Filter: (act.company_id = past.company_id)
21. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.00..0.05 rows=1 width=40) (actual rows= loops=)

  • Join Filter: (act.company_id = fut.company_id)
22. 0.000 0.000 ↓ 0.0

CTE Scan on act (cost=0.00..0.02 rows=1 width=28) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

CTE Scan on fut (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

CTE Scan on past (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)

25.          

CTE c

26. 0.000 0.000 ↓ 0.0

Append (cost=128,083.23..389,172.30 rows=414,991 width=48) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Gather (cost=128,083.23..253,527.46 rows=23,120 width=48) (actual rows= loops=)

  • Workers Planned: 2
28. 0.000 0.000 ↓ 0.0

Parallel Hash Join (cost=127,083.23..250,215.46 rows=9,633 width=48) (actual rows= loops=)

  • Hash Cond: (customers.guardian_id = c_7.id)
29. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on customers (cost=0.00..120,882.77 rows=60,334 width=16) (actual rows= loops=)

  • Filter: (guardian_id IS NOT NULL)
30. 0.000 0.000 ↓ 0.0

Parallel Hash (cost=120,882.77..120,882.77 rows=377,877 width=8) (actual rows= loops=)

31. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on customers c_7 (cost=0.00..120,882.77 rows=377,877 width=8) (actual rows= loops=)

32. 0.000 0.000 ↓ 0.0

Seq Scan on customers customers_1 (cost=0.00..129,419.98 rows=391,871 width=48) (actual rows= loops=)

  • Filter: ((sponsor IS NOT NULL) AND (guardian_id IS NULL) AND (((customer_type)::text <> 'PreEmp'::text) OR (customer_type IS NULL)))
33.          

CTE co_cat

34. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=9,363.42..9,363.51 rows=1 width=12) (actual rows= loops=)

  • Group Key: co_7.sponsor_id
35. 0.000 0.000 ↓ 0.0

Sort (cost=9,363.42..9,363.45 rows=10 width=8) (actual rows= loops=)

  • Sort Key: co_7.sponsor_id
36. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.00..9,363.26 rows=10 width=8) (actual rows= loops=)

  • Join Filter: (co_7.sponsor_id = c_8.sponsor)
37. 0.000 0.000 ↓ 0.0

CTE Scan on co co_7 (cost=0.00..0.02 rows=1 width=4) (actual rows= loops=)

  • Filter: (status = 'active (new launch)'::text)
38. 0.000 0.000 ↓ 0.0

CTE Scan on c c_8 (cost=0.00..9,337.30 rows=2,075 width=8) (actual rows= loops=)

  • Filter: (user_type = 'employee'::text)
39.          

CTE rev

40. 0.000 0.000 ↓ 0.0

Append (cost=10,164.05..11,909.14 rows=3 width=8) (actual rows= loops=)

41. 0.000 0.000 ↓ 0.0

Finalize Aggregate (cost=10,164.05..10,164.06 rows=1 width=8) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Gather (cost=10,163.83..10,164.04 rows=2 width=8) (actual rows= loops=)

  • Workers Planned: 2
43. 0.000 0.000 ↓ 0.0

Partial Aggregate (cost=9,163.83..9,163.84 rows=1 width=8) (actual rows= loops=)

44. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.70..9,163.39 rows=178 width=8) (actual rows= loops=)

45. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.42..9,108.76 rows=178 width=4) (actual rows= loops=)

46. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on appointments a_3 (cost=0.00..7,960.32 rows=180 width=4) (actual rows= loops=)

  • Filter: (('2020-08-01 00:00:00'::timestamp without time zone = date_trunc('month'::text, (appointment_date)::timestamp with time zone)) AND ((vendor_status)::text = ANY ('{received,partially_received,partial_received,completed,verification_required,received_reports,verification_required}'::text[])))
47. 0.000 0.000 ↓ 0.0

Index Scan using index_appointment_packages_on_appointment_id on appointment_packages ap (cost=0.42..6.37 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (appointment_id = a_3.id)
48. 0.000 0.000 ↓ 0.0

Index Scan using packages_pkey on packages p (cost=0.28..0.31 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (id = ap.package_id)
49. 0.000 0.000 ↓ 0.0

Aggregate (cost=98.27..98.28 rows=1 width=8) (actual rows= loops=)

50. 0.000 0.000 ↓ 0.0

Hash Join (cost=2.15..98.25 rows=8 width=8) (actual rows= loops=)

  • Hash Cond: (pe.company_program_definition_id = cpd.id)
51. 0.000 0.000 ↓ 0.0

Seq Scan on program_enrollments pe (cost=0.00..96.08 rows=8 width=4) (actual rows= loops=)

  • Filter: (((status)::text = ANY ('{inprogress,completed}'::text[])) AND (date_trunc('month'::text, (created_at + '05:30:00'::interval)) = '2020-08-01 00:00:00'::timestamp without time zone))
52. 0.000 0.000 ↓ 0.0

Hash (cost=1.51..1.51 rows=51 width=12) (actual rows= loops=)

53. 0.000 0.000 ↓ 0.0

Seq Scan on company_program_definitions cpd (cost=0.00..1.51 rows=51 width=12) (actual rows= loops=)

54. 0.000 0.000 ↓ 0.0

Aggregate (cost=1,646.74..1,646.75 rows=1 width=8) (actual rows= loops=)

55. 0.000 0.000 ↓ 0.0

Seq Scan on user_prescription_details (cost=0.00..1,646.62 rows=50 width=8) (actual rows= loops=)

  • Filter: (((status)::text = 'delivered'::text) AND (date_trunc('month'::text, (created_at + '05:30:00'::interval)) = '2020-08-01 00:00:00'::timestamp without time zone))
56.          

CTE ent

57. 0.000 0.000 ↓ 0.0

Aggregate (cost=10,307.95..10,307.97 rows=1 width=32) (actual rows= loops=)

58. 0.000 0.000 ↓ 0.0

WindowAgg (cost=10,293.95..10,300.95 rows=400 width=48) (actual rows= loops=)

59. 0.000 0.000 ↓ 0.0

Sort (cost=10,293.95..10,294.95 rows=400 width=8) (actual rows= loops=)

  • Sort Key: t_3.c DESC
60. 0.000 0.000 ↓ 0.0

Subquery Scan on t_3 (cost=10,265.66..10,276.66 rows=400 width=8) (actual rows= loops=)

61. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=10,265.66..10,272.66 rows=400 width=34) (actual rows= loops=)

  • Group Key: e.name
62. 0.000 0.000 ↓ 0.0

Sort (cost=10,265.66..10,266.66 rows=400 width=30) (actual rows= loops=)

  • Sort Key: e.name
63. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,000.56..10,248.37 rows=400 width=30) (actual rows= loops=)

64. 0.000 0.000 ↓ 0.0

Gather (cost=1,000.29..10,122.01 rows=430 width=8) (actual rows= loops=)

  • Workers Planned: 2
65. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.29..9,079.01 rows=179 width=8) (actual rows= loops=)

66. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on appointments a_4 (cost=0.00..7,960.32 rows=180 width=8) (actual rows= loops=)

  • Filter: (('2020-08-01 00:00:00'::timestamp without time zone = date_trunc('month'::text, (appointment_date)::timestamp with time zone)) AND ((vendor_status)::text = ANY ('{received,partially_received,partial_received,completed,verification_required,received_reports,verification_required}'::text[])))
67. 0.000 0.000 ↓ 0.0

Index Scan using providers_pkey on providers p_1 (cost=0.29..6.21 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (id = a_4.provider_id)
68. 0.000 0.000 ↓ 0.0

Index Scan using enterprises_pkey on enterprises e (cost=0.27..0.29 rows=1 width=30) (actual rows= loops=)

  • Index Cond: (id = p_1.enterprise_id)
69.          

CTE apt_conf

70. 0.000 0.000 ↓ 0.0

Aggregate (cost=427,407.32..427,407.33 rows=1 width=40) (actual rows= loops=)

71.          

CTE c

72. 0.000 0.000 ↓ 0.0

Append (cost=152,375.25..355,949.54 rows=269,918 width=40) (actual rows= loops=)

73. 0.000 0.000 ↓ 0.0

Merge Join (cost=152,375.25..223,460.47 rows=37,163 width=40) (actual rows= loops=)

  • Merge Cond: (f.guardian_id = customers_2.id)
74. 0.000 0.000 ↓ 0.0

Index Scan using index_customers_on_guardian_id on customers f (cost=0.42..434,149.42 rows=906,904 width=8) (actual rows= loops=)

75. 0.000 0.000 ↓ 0.0

Sort (cost=152,373.61..152,955.49 rows=232,755 width=8) (actual rows= loops=)

  • Sort Key: customers_2.id
76. 0.000 0.000 ↓ 0.0

Seq Scan on customers customers_2 (cost=0.00..128,440.30 rows=232,755 width=8) (actual rows= loops=)

  • Filter: ((sponsor IS NOT NULL) AND (sponsor <> 57))
77. 0.000 0.000 ↓ 0.0

Seq Scan on customers customers_3 (cost=0.00..128,440.30 rows=232,755 width=40) (actual rows= loops=)

  • Filter: ((sponsor IS NOT NULL) AND (sponsor <> 57))
78.          

CTE a

79. 0.000 0.000 ↓ 0.0

Hash Join (cost=36,030.70..65,864.38 rows=7,779 width=117) (actual rows= loops=)

  • Hash Cond: (a1.appointment_id = appointments.id)
80. 0.000 0.000 ↓ 0.0

Seq Scan on appointment_timelines a1 (cost=0.00..25,768.50 rows=531,650 width=104) (actual rows= loops=)

81. 0.000 0.000 ↓ 0.0

Hash (cost=36,008.94..36,008.94 rows=1,741 width=17) (actual rows= loops=)

82. 0.000 0.000 ↓ 0.0

Hash Join (cost=10,827.33..36,008.94 rows=1,741 width=17) (actual rows= loops=)

  • Hash Cond: (appointments.appointmentee_id = c_9.id)
83. 0.000 0.000 ↓ 0.0

Gather (cost=1,000.00..9,008.02 rows=477 width=21) (actual rows= loops=)

  • Workers Planned: 2
84. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on appointments (cost=0.00..7,960.32 rows=199 width=21) (actual rows= loops=)

  • Filter: ((health_camp_id IS NULL) AND (id <> 42537) AND (id <> 42993) AND ((appointment_type)::text = ANY ('{package,Package,lab_test}'::text[])) AND ('2020-08-01 00:00:00'::timestamp without time zone = date_trunc('month'::text, (appointment_date)::timestamp with time zone)))
85. 0.000 0.000 ↓ 0.0

Hash (cost=5,398.36..5,398.36 rows=269,918 width=4) (actual rows= loops=)

86. 0.000 0.000 ↓ 0.0

CTE Scan on c c_9 (cost=0.00..5,398.36 rows=269,918 width=4) (actual rows= loops=)

87.          

CTE apt

88. 0.000 0.000 ↓ 0.0

Subquery Scan on t_4 (cost=5,282.12..5,593.28 rows=1 width=636) (actual rows= loops=)

  • Filter: ((t_4.status_change ~~* '%to confirmed'::text) AND (t_4.status_change <> 'confirmed to confirmed'::text))
89. 0.000 0.000 ↓ 0.0

WindowAgg (cost=5,282.12..5,476.60 rows=7,779 width=636) (actual rows= loops=)

90. 0.000 0.000 ↓ 0.0

Sort (cost=5,282.12..5,301.57 rows=7,779 width=572) (actual rows= loops=)

  • Sort Key: a_5.appointment_id, a_5.created_at, a_5.id
91. 0.000 0.000 ↓ 0.0

WindowAgg (cost=2,628.81..2,784.39 rows=7,779 width=572) (actual rows= loops=)

92. 0.000 0.000 ↓ 0.0

Sort (cost=2,628.81..2,648.26 rows=7,779 width=564) (actual rows= loops=)

  • Sort Key: a_5.appointment_id, a_5.created_at
93. 0.000 0.000 ↓ 0.0

CTE Scan on a a_5 (cost=0.00..155.58 rows=7,779 width=564) (actual rows= loops=)

94.          

CTE no_sunday

95. 0.000 0.000 ↓ 0.0

CTE Scan on apt (cost=0.00..0.05 rows=1 width=536) (actual rows= loops=)

96. 0.000 0.000 ↓ 0.0

CTE Scan on no_sunday (cost=0.00..0.02 rows=1 width=16) (actual rows= loops=)

97.          

CTE apt_dig

98. 0.000 0.000 ↓ 0.0

Aggregate (cost=401,703.62..401,703.63 rows=1 width=32) (actual rows= loops=)

99.          

CTE c

100. 0.000 0.000 ↓ 0.0

Append (cost=152,375.25..355,949.54 rows=269,918 width=40) (actual rows= loops=)

101. 0.000 0.000 ↓ 0.0

Merge Join (cost=152,375.25..223,460.47 rows=37,163 width=40) (actual rows= loops=)

  • Merge Cond: (f_1.guardian_id = customers_4.id)
102. 0.000 0.000 ↓ 0.0

Index Scan using index_customers_on_guardian_id on customers f_1 (cost=0.42..434,149.42 rows=906,904 width=8) (actual rows= loops=)

103. 0.000 0.000 ↓ 0.0

Sort (cost=152,373.61..152,955.49 rows=232,755 width=8) (actual rows= loops=)

  • Sort Key: customers_4.id
104. 0.000 0.000 ↓ 0.0

Seq Scan on customers customers_4 (cost=0.00..128,440.30 rows=232,755 width=8) (actual rows= loops=)

  • Filter: ((sponsor IS NOT NULL) AND (sponsor <> 57))
105. 0.000 0.000 ↓ 0.0

Seq Scan on customers customers_5 (cost=0.00..128,440.30 rows=232,755 width=40) (actual rows= loops=)

  • Filter: ((sponsor IS NOT NULL) AND (sponsor <> 57))
106. 0.000 0.000 ↓ 0.0

Hash Join (cost=39,336.68..45,749.97 rows=273 width=16) (actual rows= loops=)

  • Hash Cond: (c_10.id = a_6.appointmentee_id)
107. 0.000 0.000 ↓ 0.0

CTE Scan on c c_10 (cost=0.00..5,398.36 rows=269,918 width=4) (actual rows= loops=)

108. 0.000 0.000 ↓ 0.0

Hash (cost=39,335.74..39,335.74 rows=75 width=20) (actual rows= loops=)

109. 0.000 0.000 ↓ 0.0

Nested Loop (cost=35,101.68..39,335.74 rows=75 width=20) (actual rows= loops=)

  • Join Filter: (appointment_timelines.appointment_id = a_6.id)
110. 0.000 0.000 ↓ 0.0

Nested Loop (cost=35,101.26..39,292.77 rows=82 width=24) (actual rows= loops=)

111. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=35,100.84..37,035.96 rows=277 width=12) (actual rows= loops=)

  • Group Key: appointment_timelines.appointment_id
  • Filter: ('2020-08-01 00:00:00'::timestamp without time zone = date_trunc('month'::text, (min(appointment_timelines.created_at) + '05:30:00'::interval)))
112. 0.000 0.000 ↓ 0.0

Sort (cost=35,100.84..35,342.47 rows=96,654 width=12) (actual rows= loops=)

  • Sort Key: appointment_timelines.appointment_id
113. 0.000 0.000 ↓ 0.0

Seq Scan on appointment_timelines (cost=0.00..27,097.62 rows=96,654 width=12) (actual rows= loops=)

  • Filter: ((vendor_status)::text = ANY ('{received,partially_received}'::text[]))
114. 0.000 0.000 ↓ 0.0

Index Scan using index_health_assessments_on_appointment_id on health_assessments ha (cost=0.42..8.13 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (appointment_id = appointment_timelines.appointment_id)
  • Filter: (((status)::text = 'done'::text) AND (((min(appointment_timelines.created_at) + '05:30:00'::interval)) <= updated_at))
115. 0.000 0.000 ↓ 0.0

Index Scan using appointments_pkey on appointments a_6 (cost=0.42..0.51 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (id = ha.appointment_id)
  • Filter: ((appointment_type)::text = ANY ('{package,Package,lab_test}'::text[]))
116. 0.000 0.000 ↓ 0.0

Result (cost=0.02..78,960.21 rows=19 width=44) (actual rows= loops=)

117. 0.000 0.000 ↓ 0.0

Append (cost=0.02..78,959.97 rows=19 width=68) (actual rows= loops=)

118. 0.000 0.000 ↓ 0.0

Result (cost=0.02..72,698.70 rows=14 width=68) (actual rows= loops=)

119. 0.000 0.000 ↓ 0.0

Append (cost=0.02..72,698.52 rows=14 width=44) (actual rows= loops=)

120. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=44) (actual rows= loops=)

121. 0.000 0.000 ↓ 0.0

CTE Scan on co (cost=0.00..0.02 rows=1 width=0) (actual rows= loops=)

  • Filter: (status = 'active (new launch)'::text)
122. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=44) (actual rows= loops=)

123. 0.000 0.000 ↓ 0.0

CTE Scan on co_cat (cost=0.00..0.02 rows=1 width=0) (actual rows= loops=)

  • Filter: (c > 2000)
124. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.03..0.04 rows=1 width=44) (actual rows= loops=)

125. 0.000 0.000 ↓ 0.0

CTE Scan on co_cat co_cat_1 (cost=0.00..0.03 rows=1 width=0) (actual rows= loops=)

  • Filter: ((c >= 500) AND (c <= 2,000))
126. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.03..0.04 rows=1 width=44) (actual rows= loops=)

127. 0.000 0.000 ↓ 0.0

CTE Scan on co_cat co_cat_2 (cost=0.00..0.03 rows=1 width=0) (actual rows= loops=)

  • Filter: ((c > 0) AND (c < 500))
128. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=44) (actual rows= loops=)

129. 0.000 0.000 ↓ 0.0

CTE Scan on co_cat co_cat_3 (cost=0.00..0.02 rows=1 width=0) (actual rows= loops=)

  • Filter: (c = 0)
130. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=44) (actual rows= loops=)

131. 0.000 0.000 ↓ 0.0

CTE Scan on co co_1 (cost=0.00..0.02 rows=1 width=0) (actual rows= loops=)

  • Filter: (status = 'churned'::text)
132. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=44) (actual rows= loops=)

133. 0.000 0.000 ↓ 0.0

CTE Scan on co co_2 (cost=0.00..0.02 rows=1 width=0) (actual rows= loops=)

  • Filter: (status = ANY ('{active,""active (new launch)""}'::text[]))
134. 0.000 0.000 ↓ 0.0

Aggregate (cost=9,363.28..9,363.29 rows=1 width=44) (actual rows= loops=)

135. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..9,363.26 rows=10 width=0) (actual rows= loops=)

  • Join Filter: (co_3.sponsor_id = c.sponsor)
136. 0.000 0.000 ↓ 0.0

CTE Scan on co co_3 (cost=0.00..0.02 rows=1 width=4) (actual rows= loops=)

  • Filter: (status = 'churned'::text)
137. 0.000 0.000 ↓ 0.0

CTE Scan on c (cost=0.00..9,337.30 rows=2,075 width=4) (actual rows= loops=)

  • Filter: (user_type = 'employee'::text)
138. 0.000 0.000 ↓ 0.0

Aggregate (cost=9,363.28..9,363.29 rows=1 width=44) (actual rows= loops=)

139. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..9,363.26 rows=10 width=0) (actual rows= loops=)

  • Join Filter: (co_4.sponsor_id = c_1.sponsor)
140. 0.000 0.000 ↓ 0.0

CTE Scan on co co_4 (cost=0.00..0.02 rows=1 width=4) (actual rows= loops=)

  • Filter: (status = 'churned'::text)
141. 0.000 0.000 ↓ 0.0

CTE Scan on c c_1 (cost=0.00..9,337.30 rows=2,075 width=4) (actual rows= loops=)

  • Filter: (user_type = 'dependent'::text)
142. 0.000 0.000 ↓ 0.0

Aggregate (cost=11,412.28..11,412.29 rows=1 width=44) (actual rows= loops=)

143. 0.000 0.000 ↓ 0.0

CTE Scan on c c_2 (cost=0.00..11,412.25 rows=10 width=0) (actual rows= loops=)

  • Filter: ((user_type = 'employee'::text) AND (date_trunc('month'::text, d) = '2020-08-01 00:00:00'::timestamp without time zone))
144. 0.000 0.000 ↓ 0.0

Aggregate (cost=11,412.28..11,412.29 rows=1 width=44) (actual rows= loops=)

145. 0.000 0.000 ↓ 0.0

CTE Scan on c c_3 (cost=0.00..11,412.25 rows=10 width=0) (actual rows= loops=)

  • Filter: ((user_type = 'dependent'::text) AND (date_trunc('month'::text, d) = '2020-08-01 00:00:00'::timestamp without time zone))
146. 0.000 0.000 ↓ 0.0

Aggregate (cost=10,379.96..10,379.97 rows=1 width=44) (actual rows= loops=)

147. 0.000 0.000 ↓ 0.0

CTE Scan on c c_4 (cost=0.00..10,374.78 rows=2,075 width=0) (actual rows= loops=)

  • Filter: (date_trunc('month'::text, d) = '2020-08-01 00:00:00'::timestamp without time zone)
148. 0.000 0.000 ↓ 0.0

Aggregate (cost=10,383.45..10,383.47 rows=1 width=44) (actual rows= loops=)

149. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..10,383.45 rows=3 width=0) (actual rows= loops=)

  • Join Filter: (c_5.sponsor = co_5.sponsor_id)
150. 0.000 0.000 ↓ 0.0

CTE Scan on co co_5 (cost=0.00..0.02 rows=1 width=4) (actual rows= loops=)

  • Filter: (status = ANY ('{active,""active (new launch)""}'::text[]))
151. 0.000 0.000 ↓ 0.0

CTE Scan on c c_5 (cost=0.00..10,374.78 rows=692 width=4) (actual rows= loops=)

  • Filter: ((d < '2020-09-01 00:00:00'::timestamp without time zone) AND (user_type = 'employee'::text))
152. 0.000 0.000 ↓ 0.0

Aggregate (cost=10,383.45..10,383.47 rows=1 width=44) (actual rows= loops=)

153. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..10,383.45 rows=3 width=0) (actual rows= loops=)

  • Join Filter: (c_6.sponsor = co_6.sponsor_id)
154. 0.000 0.000 ↓ 0.0

CTE Scan on co co_6 (cost=0.00..0.02 rows=1 width=4) (actual rows= loops=)

  • Filter: (status = ANY ('{active,""active (new launch)""}'::text[]))
155. 0.000 0.000 ↓ 0.0

CTE Scan on c c_6 (cost=0.00..10,374.78 rows=692 width=4) (actual rows= loops=)

  • Filter: ((d < '2020-09-01 00:00:00'::timestamp without time zone) AND (user_type = 'dependent'::text))
156. 0.000 0.000 ↓ 0.0

Aggregate (cost=1,512.56..1,512.57 rows=1 width=68) (actual rows= loops=)

157. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.42..1,512.38 rows=68 width=4) (actual rows= loops=)

158. 0.000 0.000 ↓ 0.0

Seq Scan on consultation_feedbacks cf (cost=0.00..861.82 rows=79 width=8) (actual rows= loops=)

  • Filter: (((source_type)::text = 'Appointment'::text) AND (date_trunc('month'::text, (created_at + '05:30:00'::interval)) = '2020-08-01 00:00:00'::timestamp without time zone))
159. 0.000 0.000 ↓ 0.0

Index Scan using appointments_pkey on appointments a (cost=0.42..8.23 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = cf.source_id)
  • Filter: ((appointment_type)::text <> ALL ('{dental,vision}'::text[]))
160. 0.000 0.000 ↓ 0.0

Aggregate (cost=861.88..861.89 rows=1 width=68) (actual rows= loops=)

161. 0.000 0.000 ↓ 0.0

Seq Scan on consultation_feedbacks (cost=0.00..861.82 rows=24 width=4) (actual rows= loops=)

  • Filter: (((source_type)::text = 'ConsultationRequest'::text) AND (date_trunc('month'::text, (created_at + '05:30:00'::interval)) = '2020-08-01 00:00:00'::timestamp without time zone))
162. 0.000 0.000 ↓ 0.0

Aggregate (cost=861.84..861.85 rows=1 width=68) (actual rows= loops=)

163. 0.000 0.000 ↓ 0.0

Seq Scan on consultation_feedbacks consultation_feedbacks_1 (cost=0.00..861.82 rows=6 width=4) (actual rows= loops=)

  • Filter: (((source_type)::text = 'Fitmein::Appointment'::text) AND (date_trunc('month'::text, (created_at + '05:30:00'::interval)) = '2020-08-01 00:00:00'::timestamp without time zone))
164. 0.000 0.000 ↓ 0.0

Aggregate (cost=1,512.40..1,512.41 rows=1 width=68) (actual rows= loops=)

165. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.42..1,512.39 rows=1 width=4) (actual rows= loops=)

166. 0.000 0.000 ↓ 0.0

Seq Scan on consultation_feedbacks cf_1 (cost=0.00..861.82 rows=79 width=8) (actual rows= loops=)

  • Filter: (((source_type)::text = 'Appointment'::text) AND (date_trunc('month'::text, (created_at + '05:30:00'::interval)) = '2020-08-01 00:00:00'::timestamp without time zone))
167. 0.000 0.000 ↓ 0.0

Index Scan using appointments_pkey on appointments a_1 (cost=0.42..8.23 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = cf_1.source_id)
  • Filter: ((appointment_type)::text = 'dental'::text)
168. 0.000 0.000 ↓ 0.0

Aggregate (cost=1,512.40..1,512.41 rows=1 width=68) (actual rows= loops=)

169. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.42..1,512.39 rows=2 width=4) (actual rows= loops=)

170. 0.000 0.000 ↓ 0.0

Seq Scan on consultation_feedbacks cf_2 (cost=0.00..861.82 rows=79 width=8) (actual rows= loops=)

  • Filter: (((source_type)::text = 'Appointment'::text) AND (date_trunc('month'::text, (created_at + '05:30:00'::interval)) = '2020-08-01 00:00:00'::timestamp without time zone))
171. 0.000 0.000 ↓ 0.0

Index Scan using appointments_pkey on appointments a_2 (cost=0.42..8.23 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = cf_2.source_id)
  • Filter: ((appointment_type)::text = 'vision'::text)
172. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.07..0.08 rows=1 width=44) (actual rows= loops=)

173. 0.000 0.000 ↓ 0.0

CTE Scan on rev (cost=0.00..0.06 rows=3 width=8) (actual rows= loops=)

174. 0.000 0.000 ↓ 0.0

Subquery Scan on "*SELECT* 21" (cost=0.00..0.03 rows=1 width=44) (actual rows= loops=)

175. 0.000 0.000 ↓ 0.0

CTE Scan on ent (cost=0.00..0.02 rows=1 width=68) (actual rows= loops=)

176. 0.000 0.000 ↓ 0.0

CTE Scan on apt_conf (cost=0.00..0.02 rows=1 width=44) (actual rows= loops=)

177. 0.000 0.000 ↓ 0.0

Subquery Scan on "*SELECT* 23" (cost=0.00..0.03 rows=1 width=44) (actual rows= loops=)

178. 0.000 0.000 ↓ 0.0

CTE Scan on apt_dig (cost=0.00..0.02 rows=1 width=68) (actual rows= loops=)