explain.depesz.com

PostgreSQL's explain analyze made readable

Result: JUvHg

Settings
# exclusive inclusive rows x rows loops node
1. 8,501.367 53,285.269 ↓ 5.3 638,535 1

Merge Left Join (cost=2,120,290.88..2,123,202.45 rows=120,241 width=140) (actual time=41,391.184..53,285.269 rows=638,535 loops=1)

  • Merge Cond: ((projects.account_id = cost_exchange_rates.account_id) AND ((sa.currency)::text = (cost_exchange_rates.currency)::text))
  • Join Filter: ((cost_exchange_rates.start_date <= "*SELECT* 1_1".date) AND (cost_exchange_rates.end_date >= "*SELECT* 1_1".date))
  • Rows Removed by Join Filter: 34221967
2. 780.691 41,456.885 ↓ 5.3 638,535 1

Sort (cost=2,120,046.02..2,120,346.62 rows=120,241 width=176) (actual time=41,388.878..41,456.885 rows=638,535 loops=1)

  • Sort Key: projects.account_id, sa.currency
  • Sort Method: quicksort Memory: 184853kB
3. 9,512.619 40,676.194 ↓ 5.3 638,535 1

Merge Left Join (cost=2,108,792.39..2,109,900.34 rows=120,241 width=176) (actual time=27,326.366..40,676.194 rows=638,535 loops=1)

  • Merge Cond: ((projects.account_id = exchange_rates_by_months.account_id) AND (("*SELECT* 1".currency)::text = (exchange_rates_by_months.currency)::text))
  • Join Filter: ((exchange_rates_by_months.start_date <= "*SELECT* 1_1".date) AND (exchange_rates_by_months.end_date >= "*SELECT* 1_1".date))
  • Rows Removed by Join Filter: 38541529
4. 797.320 27,392.736 ↓ 5.3 638,535 1

Sort (cost=2,108,547.52..2,108,848.13 rows=120,241 width=168) (actual time=27,321.774..27,392.736 rows=638,535 loops=1)

  • Sort Key: projects.account_id, ""*SELECT* 1"".currency
  • Sort Method: quicksort Memory: 159598kB
5. 354.852 26,595.416 ↓ 5.3 638,535 1

Merge Left Join (cost=2,067,295.63..2,098,401.85 rows=120,241 width=168) (actual time=25,242.303..26,595.416 rows=638,535 loops=1)

  • Merge Cond: (projects.id = discounts.project_id)
  • Join Filter: (("*SELECT* 1_1".date >= discounts.start_date) AND ("*SELECT* 1_1".date <= discounts.end_date) AND (((discounts.discountable_id = "*SELECT* 1_1".user_id) AND ((discounts.discountable_type)::text = 'User'::text)) OR ((discounts.discountable_id = "*SELECT* 1_1".epic_id) AND ((discounts.discountable_type)::text = 'Epic'::text))))
  • Rows Removed by Join Filter: 599801
6. 672.990 26,174.488 ↓ 5.3 638,460 1

Merge Join (cost=2,067,272.86..2,092,559.41 rows=120,241 width=164) (actual time=25,241.908..26,174.488 rows=638,460 loops=1)

  • Merge Cond: ((projects.id = ""*SELECT* 1"".project_id) AND ((COALESCE(""*SELECT* 1_1"".activity_id, sa.activity_id)) = ""*SELECT* 1"".activity_id))
  • Join Filter: (("*SELECT* 1_1".date >= "*SELECT* 1".start_date) AND (("*SELECT* 1_1".date <= "*SELECT* 1".end_date) OR ("*SELECT* 1".end_date IS NULL)))
  • Rows Removed by Join Filter: 229908
7. 1,012.435 24,571.848 ↓ 5.2 821,415 1

Sort (cost=2,020,441.95..2,020,834.90 rows=157,180 width=136) (actual time=24,439.770..24,571.848 rows=821,415 loops=1)

  • Sort Key: projects.id, (COALESCE(""*SELECT* 1_1"".activity_id, sa.activity_id))
  • Sort Method: quicksort Memory: 144101kB
8. 376.835 23,559.413 ↓ 5.4 849,952 1

Hash Join (cost=1,132,107.56..2,006,875.70 rows=157,180 width=136) (actual time=2,553.685..23,559.413 rows=849,952 loops=1)

  • Hash Cond: (projects.account_id = accounts.id)
9. 209.213 23,182.457 ↓ 2.4 1,116,116 1

Append (cost=1,132,088.89..2,000,889.02 rows=471,540 width=136) (actual time=2,553.543..23,182.457 rows=1,116,116 loops=1)

10. 827.543 22,559.404 ↓ 2.7 1,087,210 1

Hash Join (cost=1,132,088.89..1,557,773.60 rows=403,983 width=108) (actual time=2,553.542..22,559.404 rows=1,087,210 loops=1)

  • Hash Cond: (projects.account_id = accounts_1.id)
  • Join Filter: ((((""*SELECT* 1_1"".vacation_user_id)::double precision) IS NULL) OR (((""*SELECT* 1_1"".vacation_hours)::double precision) < (COALESCE(sa.capacity, accounts_1.default_capacity))::double precision))
  • Rows Removed by Join Filter: 13596
11. 668.804 21,731.727 ↑ 1.1 1,100,806 1

Hash Left Join (cost=1,132,069.92..1,539,437.01 rows=1,199,950 width=144) (actual time=2,553.385..21,731.727 rows=1,100,806 loops=1)

  • Hash Cond: ((projects.account_id = sa.account_id) AND ("*SELECT* 1_1".user_id = sa.user_id))
  • Join Filter: (("*SELECT* 1_1".date >= sa.start_date) AND ("*SELECT* 1_1".date <= sa.end_date))
  • Rows Removed by Join Filter: 258899
12. 456.612 21,059.528 ↑ 1.1 1,100,806 1

Hash Join (cost=1,131,915.40..1,438,239.63 rows=1,199,950 width=120) (actual time=2,549.948..21,059.528 rows=1,100,806 loops=1)

  • Hash Cond: ("*SELECT* 1_1".project_id = projects.id)
13. 205.255 20,601.077 ↑ 1.1 1,100,806 1

Append (cost=1,131,686.63..1,422,859.20 rows=1,199,950 width=116) (actual time=2,548.093..20,601.077 rows=1,100,806 loops=1)

14. 190.375 3,701.609 ↑ 1.2 396,845 1

Result (cost=1,131,686.63..1,226,655.23 rows=495,989 width=116) (actual time=2,548.092..3,701.609 rows=396,845 loops=1)

15. 65.156 3,511.234 ↑ 1.2 396,845 1

Append (cost=1,131,686.63..1,220,455.37 rows=495,989 width=140) (actual time=2,548.086..3,511.234 rows=396,845 loops=1)

16. 91.929 3,003.969 ↑ 1.4 338,629 1

Subquery Scan on *SELECT* 1_1 (cost=1,131,686.63..1,155,495.07 rows=457,239 width=114) (actual time=2,548.085..3,003.969 rows=338,629 loops=1)

17. 140.128 2,912.040 ↑ 1.4 338,629 1

Merge Left Join (cost=1,131,686.63..1,148,636.49 rows=457,239 width=134) (actual time=2,548.082..2,912.040 rows=338,629 loops=1)

  • Merge Cond: ((projects_1.account_id = summary_vacations_by_dates.account_id) AND (generate_series.generate_series = summary_vacations_by_dates.date) AND (plan_rows.user_id = summary_vacations_by_dates.user_id))
18. 158.922 2,580.595 ↑ 1.4 338,629 1

Merge Anti Join (cost=525,089.35..531,687.96 rows=457,239 width=66) (actual time=2,363.689..2,580.595 rows=338,629 loops=1)

  • Merge Cond: ((projects_1.account_id = non_working_intervals_by_dates.account_id) AND (generate_series.generate_series = non_working_intervals_by_dates.date) AND (plan_rows.user_id = non_working_intervals_by_dates.user_id))
19. 1,349.056 2,362.118 ↑ 1.7 346,275 1

Sort (cost=519,071.36..520,519.29 rows=579,175 width=66) (actual time=2,310.166..2,362.118 rows=346,275 loops=1)

  • Sort Key: projects_1.account_id, generate_series.generate_series, plan_rows.user_id
  • Sort Method: quicksort Memory: 60983kB
20. 203.249 1,013.062 ↑ 1.7 346,275 1

Merge Left Join (cost=12,929.64..463,633.77 rows=579,175 width=66) (actual time=327.935..1,013.062 rows=346,275 loops=1)

  • Merge Cond: (plan_items.plan_row_uuid = pa.plan_row_uuid)
  • Join Filter: (((pa.epic_id = plan_rows.epic_id) OR (plan_rows.epic_id IS NULL)) AND (pa.project_plan_id = project_plans.id) AND (pa.user_id = plan_rows.user_id) AND ((generate_series.generate_series)::date >= pa.start_date) AND ((generate_series.generate_series)::date <= pa.end_date))
  • Rows Removed by Join Filter: 3247
21. 100.348 502.989 ↑ 1.7 346,275 1

Nested Loop (cost=3,971.09..448,257.03 rows=579,175 width=70) (actual time=61.148..502.989 rows=346,275 loops=1)

22. 21.141 130.021 ↓ 1.2 27,262 1

Merge Join (cost=3,971.09..8,084.02 rows=23,167 width=70) (actual time=61.112..130.021 rows=27,262 loops=1)

  • Merge Cond: (plan_rows.uuid = plan_items.plan_row_uuid)
23. 41.437 41.437 ↑ 1.0 42,344 1

Index Scan using plan_rows_uuid_key on plan_rows (cost=0.29..3,663.60 rows=42,428 width=28) (actual time=0.022..41.437 rows=42,344 loops=1)

  • Filter: (user_id IS NOT NULL)
  • Rows Removed by Filter: 5762
24. 24.994 67.443 ↓ 1.1 29,797 1

Sort (cost=3,970.18..4,035.85 rows=26,267 width=58) (actual time=61.067..67.443 rows=29,797 loops=1)

  • Sort Key: plan_items.plan_row_uuid
  • Sort Method: quicksort Memory: 4959kB
25. 9.793 42.449 ↓ 1.1 29,797 1

Hash Join (cost=430.80..2,042.06 rows=26,267 width=58) (actual time=3.559..42.449 rows=29,797 loops=1)

  • Hash Cond: (project_plans.project_id = projects_1.id)
26. 16.088 30.788 ↓ 1.1 29,797 1

Hash Join (cost=202.03..1,744.28 rows=26,267 width=54) (actual time=1.639..30.788 rows=29,797 loops=1)

  • Hash Cond: (plan_items.project_plan_id = project_plans.id)
27. 13.106 13.106 ↓ 1.0 55,664 1

Seq Scan on plan_items (cost=0.00..1,396.10 rows=55,639 width=46) (actual time=0.007..13.106 rows=55,664 loops=1)

  • Filter: (utilization > '0'::numeric)
  • Rows Removed by Filter: 264
28. 0.473 1.594 ↑ 1.0 2,851 1

Hash (cost=166.39..166.39 rows=2,851 width=8) (actual time=1.593..1.594 rows=2,851 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 144kB
29. 1.121 1.121 ↑ 1.0 2,851 1

Seq Scan on project_plans (cost=0.00..166.39 rows=2,851 width=8) (actual time=0.006..1.121 rows=2,851 loops=1)

  • Filter: active
  • Rows Removed by Filter: 3188
30. 0.973 1.868 ↑ 1.0 5,812 1

Hash (cost=156.12..156.12 rows=5,812 width=8) (actual time=1.868..1.868 rows=5,812 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 292kB
31. 0.895 0.895 ↑ 1.0 5,812 1

Seq Scan on projects projects_1 (cost=0.00..156.12 rows=5,812 width=8) (actual time=0.008..0.895 rows=5,812 loops=1)

32. 272.620 272.620 ↑ 1.9 13 27,262

Function Scan on generate_series (cost=0.01..18.76 rows=25 width=8) (actual time=0.004..0.010 rows=13 loops=27,262)

  • Filter: (date_part('dow'::text, generate_series) = ANY ('{1,2,3,4,5}'::double precision[]))
  • Rows Removed by Filter: 5
33. 66.013 306.824 ↓ 77.4 384,529 1

Sort (cost=8,958.54..8,970.97 rows=4,971 width=36) (actual time=266.771..306.824 rows=384,529 loops=1)

  • Sort Key: pa.plan_row_uuid
  • Sort Method: quicksort Memory: 5007kB
34. 8.604 240.811 ↓ 8.9 44,428 1

Subquery Scan on pa (cost=8,529.07..8,653.34 rows=4,971 width=36) (actual time=173.434..240.811 rows=44,428 loops=1)

35. 99.873 232.207 ↓ 8.9 44,428 1

HashAggregate (cost=8,529.07..8,603.63 rows=4,971 width=48) (actual time=173.432..232.207 rows=44,428 loops=1)

  • Group Key: plan_rows_1.project_plan_id, plan_rows_1.epic_id, plan_rows_1.user_id, plan_roles.activity_id, COALESCE(plan_roles.start_date, '1980-01-01'::date), COALESCE(lag((plan_roles.start_date - 1), 1) OVER (?), '3000-01-01'::date)
36. 41.165 132.334 ↑ 1.0 44,581 1

WindowAgg (cost=6,077.00..7,080.12 rows=44,583 width=68) (actual time=83.924..132.334 rows=44,581 loops=1)

37. 35.820 91.169 ↑ 1.0 44,581 1

Sort (cost=6,077.00..6,188.46 rows=44,583 width=52) (actual time=83.908..91.169 rows=44,581 loops=1)

  • Sort Key: plan_roles.plan_row_uuid, plan_roles.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 5023kB
38. 23.921 55.349 ↑ 1.0 44,581 1

Hash Join (cost=1,631.38..2,634.26 rows=44,583 width=52) (actual time=25.498..55.349 rows=44,581 loops=1)

  • Hash Cond: (plan_roles.plan_row_uuid = plan_rows_1.uuid)
39. 6.318 6.318 ↑ 1.0 44,581 1

Seq Scan on plan_roles (cost=0.00..885.83 rows=44,583 width=24) (actual time=0.011..6.318 rows=44,581 loops=1)

40. 14.016 25.110 ↑ 1.0 48,106 1

Hash (cost=1,030.06..1,030.06 rows=48,106 width=28) (actual time=25.110..25.110 rows=48,106 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 3180kB
41. 11.094 11.094 ↑ 1.0 48,106 1

Seq Scan on plan_rows plan_rows_1 (cost=0.00..1,030.06 rows=48,106 width=28) (actual time=0.007..11.094 rows=48,106 loops=1)

42. 44.673 59.555 ↑ 1.0 59,679 1

Sort (cost=6,017.99..6,167.27 rows=59,712 width=12) (actual time=53.516..59.555 rows=59,679 loops=1)

  • Sort Key: non_working_intervals_by_dates.account_id, non_working_intervals_by_dates.date, non_working_intervals_by_dates.user_id
  • Sort Method: quicksort Memory: 4336kB
43. 14.882 14.882 ↑ 1.0 59,712 1

Seq Scan on non_working_intervals_by_dates (cost=0.00..1,281.12 rows=59,712 width=12) (actual time=0.016..14.882 rows=59,712 loops=1)

44. 59.501 191.317 ↑ 15.5 37,180 1

Sort (cost=606,597.28..608,034.78 rows=575,000 width=44) (actual time=184.383..191.317 rows=37,180 loops=1)

  • Sort Key: summary_vacations_by_dates.account_id, summary_vacations_by_dates.date, summary_vacations_by_dates.user_id
  • Sort Method: quicksort Memory: 2844kB
45. 6.822 131.816 ↑ 17.8 32,266 1

Subquery Scan on summary_vacations_by_dates (cost=537,214.32..551,589.32 rows=575,000 width=44) (actual time=100.403..131.816 rows=32,266 loops=1)

46. 48.650 124.994 ↑ 17.8 32,266 1

HashAggregate (cost=537,214.32..545,839.32 rows=575,000 width=52) (actual time=100.401..124.994 rows=32,266 loops=1)

  • Group Key: generate_series_1.generate_series, staff_memberships.user_id, staff_memberships.account_id
47. 18.057 76.344 ↑ 134.2 32,422 1

Hash Join (cost=138.05..493,700.50 rows=4,351,382 width=21) (actual time=2.100..76.344 rows=32,422 loops=1)

  • Hash Cond: (vacations.staff_membership_id = staff_memberships.id)
  • Join Filter: ((generate_series_1.generate_series >= staff_memberships.joined_at) AND ((staff_memberships.archived_at IS NULL) OR (generate_series_1.generate_series <= staff_memberships.archived_at)))
  • Rows Removed by Join Filter: 1908
48. 9.127 56.238 ↑ 634.8 34,330 1

Nested Loop (cost=0.01..436,340.93 rows=21,792,000 width=17) (actual time=0.026..56.238 rows=34,330 loops=1)

49. 3.527 3.527 ↑ 1.0 21,792 1

Seq Scan on vacations (cost=0.00..500.92 rows=21,792 width=17) (actual time=0.014..3.527 rows=21,792 loops=1)

50. 43.584 43.584 ↑ 500.0 2 21,792

Function Scan on generate_series generate_series_1 (cost=0.01..10.01 rows=1,000 width=8) (actual time=0.001..0.002 rows=2 loops=21,792)

51. 1.042 2.049 ↑ 1.0 4,002 1

Hash (cost=88.02..88.02 rows=4,002 width=20) (actual time=2.049..2.049 rows=4,002 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 229kB
52. 1.007 1.007 ↑ 1.0 4,002 1

Seq Scan on staff_memberships (cost=0.00..88.02 rows=4,002 width=20) (actual time=0.007..1.007 rows=4,002 loops=1)

53. 30.084 442.109 ↓ 1.5 58,216 1

Hash Join (cost=1,215.85..62,092.86 rows=38,750 width=114) (actual time=7.456..442.109 rows=58,216 loops=1)

  • Hash Cond: (project_plans_1.project_id = projects_1_1.id)
  • Join Filter: (NOT (SubPlan 1))
  • Rows Removed by Join Filter: 770
54. 18.584 114.094 ↑ 1.3 58,986 1

Nested Loop (cost=987.08..61,446.50 rows=77,500 width=58) (actual time=4.415..114.094 rows=58,986 loops=1)

55. 2.248 37.205 ↑ 1.2 2,535 1

Hash Join (cost=987.08..2,546.49 rows=3,100 width=58) (actual time=4.398..37.205 rows=2,535 loops=1)

  • Hash Cond: (plan_items_1.project_plan_id = project_plans_1.id)
56. 16.896 33.380 ↓ 1.2 7,876 1

Hash Join (cost=785.05..2,327.21 rows=6,567 width=54) (actual time=2.779..33.380 rows=7,876 loops=1)

  • Hash Cond: (plan_items_1.plan_row_uuid = plan_rows_2.uuid)
57. 13.780 13.780 ↓ 1.0 55,664 1

Seq Scan on plan_items plan_items_1 (cost=0.00..1,396.10 rows=55,639 width=46) (actual time=0.008..13.780 rows=55,664 loops=1)

  • Filter: (utilization > '0'::numeric)
  • Rows Removed by Filter: 264
58. 1.098 2.704 ↓ 1.0 5,762 1

Hash (cost=714.07..714.07 rows=5,678 width=24) (actual time=2.704..2.704 rows=5,762 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 366kB
59. 1.385 1.606 ↓ 1.0 5,762 1

Bitmap Heap Scan on plan_rows plan_rows_2 (cost=108.29..714.07 rows=5,678 width=24) (actual time=0.260..1.606 rows=5,762 loops=1)

  • Recheck Cond: (user_id IS NULL)
  • Heap Blocks: exact=430
60. 0.221 0.221 ↓ 1.0 5,762 1

Bitmap Index Scan on index_plan_rows_on_user_id (cost=0.00..106.88 rows=5,678 width=0) (actual time=0.220..0.221 rows=5,762 loops=1)

  • Index Cond: (user_id IS NULL)
61. 0.467 1.577 ↑ 1.0 2,851 1

Hash (cost=166.39..166.39 rows=2,851 width=8) (actual time=1.577..1.577 rows=2,851 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 144kB
62. 1.110 1.110 ↑ 1.0 2,851 1

Seq Scan on project_plans project_plans_1 (cost=0.00..166.39 rows=2,851 width=8) (actual time=0.007..1.110 rows=2,851 loops=1)

  • Filter: active
  • Rows Removed by Filter: 3188
63. 58.305 58.305 ↑ 1.1 23 2,535

Function Scan on generate_series generate_series_2 (cost=0.01..18.76 rows=25 width=8) (actual time=0.008..0.023 rows=23 loops=2,535)

  • Filter: (date_part('dow'::text, generate_series) = ANY ('{1,2,3,4,5}'::double precision[]))
  • Rows Removed by Filter: 9
64. 1.372 3.001 ↑ 1.0 5,812 1

Hash (cost=156.12..156.12 rows=5,812 width=12) (actual time=3.001..3.001 rows=5,812 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 314kB
65. 1.629 1.629 ↑ 1.0 5,812 1

Seq Scan on projects projects_1_1 (cost=0.00..156.12 rows=5,812 width=12) (actual time=0.012..1.629 rows=5,812 loops=1)

66.          

SubPlan (for Hash Join)

67. 58.986 294.930 ↓ 0.0 0 58,986

Nested Loop (cost=0.69..16.74 rows=1 width=0) (actual time=0.005..0.005 rows=0 loops=58,986)

68. 117.972 117.972 ↑ 1.0 1 58,986

Index Scan using clients_pkey on clients clients_3 (cost=0.28..8.29 rows=1 width=4) (actual time=0.001..0.002 rows=1 loops=58,986)

  • Index Cond: (projects_1_1.client_id = id)
69. 117.972 117.972 ↓ 0.0 0 58,986

Index Only Scan using non_working_intervals_by_office_id_idx on non_working_intervals_by_dates non_working_intervals_by_dates_2 (cost=0.41..8.44 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=58,986)

  • Index Cond: ((account_id = projects_1_1.account_id) AND (office_id = clients_3.office_id) AND (date = generate_series_2.generate_series))
  • Heap Fetches: 770
70. 15,719.523 16,694.213 ↑ 1.0 703,961 1

Hash Right Join (cost=45,029.23..183,164.61 rows=703,961 width=116) (actual time=890.769..16,694.213 rows=703,961 loops=1)

  • Hash Cond: (plan_rows_3.user_id = time_logs.user_id)
  • Join Filter: ((time_logs.date >= (COALESCE(plan_roles_1.start_date, '1980-01-01'::date))) AND (time_logs.date <= (COALESCE(lag((plan_roles_1.start_date - 1), 1) OVER (?), '3000-01-01'::date))) AND (((plan_rows_3.epic_id = time_logs.epic_id) AND (plan_rows_3.project_plan_id = epics.project_plan_id)) OR ((plan_rows_3.epic_id IS NULL) AND (plan_rows_3.project_plan_id = general_epic_plans.id))))
  • Rows Removed by Join Filter: 63215381
71. 124.648 244.952 ↓ 8.9 44,428 1

HashAggregate (cost=8,529.07..8,603.63 rows=4,971 width=48) (actual time=155.926..244.952 rows=44,428 loops=1)

  • Group Key: plan_rows_3.project_plan_id, plan_rows_3.epic_id, plan_rows_3.user_id, plan_roles_1.activity_id, COALESCE(plan_roles_1.start_date, '1980-01-01'::date), COALESCE(lag((plan_roles_1.start_date - 1), 1) OVER (?), '3000-01-01'::date)
72. 34.903 120.304 ↑ 1.0 44,581 1

WindowAgg (cost=6,077.00..7,080.12 rows=44,583 width=68) (actual time=78.693..120.304 rows=44,581 loops=1)

73. 31.616 85.401 ↑ 1.0 44,581 1

Sort (cost=6,077.00..6,188.46 rows=44,583 width=52) (actual time=78.677..85.401 rows=44,581 loops=1)

  • Sort Key: plan_roles_1.plan_row_uuid, plan_roles_1.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 5023kB
74. 20.778 53.785 ↑ 1.0 44,581 1

Hash Join (cost=1,631.38..2,634.26 rows=44,583 width=52) (actual time=27.496..53.785 rows=44,581 loops=1)

  • Hash Cond: (plan_roles_1.plan_row_uuid = plan_rows_3.uuid)
75. 5.589 5.589 ↑ 1.0 44,581 1

Seq Scan on plan_roles plan_roles_1 (cost=0.00..885.83 rows=44,583 width=24) (actual time=0.014..5.589 rows=44,581 loops=1)

76. 15.637 27.418 ↑ 1.0 48,106 1

Hash (cost=1,030.06..1,030.06 rows=48,106 width=28) (actual time=27.418..27.418 rows=48,106 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 3180kB
77. 11.781 11.781 ↑ 1.0 48,106 1

Seq Scan on plan_rows plan_rows_3 (cost=0.00..1,030.06 rows=48,106 width=28) (actual time=0.009..11.781 rows=48,106 loops=1)

78. 264.085 729.738 ↑ 1.0 703,961 1

Hash (cost=27,700.65..27,700.65 rows=703,961 width=40) (actual time=729.738..729.738 rows=703,961 loops=1)

  • Buckets: 1048576 Batches: 1 Memory Usage: 62366kB
79. 341.868 465.653 ↑ 1.0 703,961 1

Hash Join (cost=1,826.58..27,700.65 rows=703,961 width=40) (actual time=24.119..465.653 rows=703,961 loops=1)

  • Hash Cond: (time_logs.epic_id = epics.id)
80. 99.779 99.779 ↑ 1.0 703,961 1

Seq Scan on time_logs (cost=0.00..16,194.61 rows=703,961 width=28) (actual time=0.058..99.779 rows=703,961 loops=1)

81. 7.568 24.006 ↑ 1.0 26,435 1

Hash (cost=1,496.14..1,496.14 rows=26,435 width=16) (actual time=24.006..24.006 rows=26,435 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 1381kB
82. 10.722 16.438 ↑ 1.0 26,435 1

Hash Left Join (cost=202.03..1,496.14 rows=26,435 width=16) (actual time=2.122..16.438 rows=26,435 loops=1)

  • Hash Cond: (epics.project_id = general_epic_plans.project_id)
  • Join Filter: (epics.project_plan_id IS NULL)
  • Rows Removed by Join Filter: 11144
83. 3.636 3.636 ↑ 1.0 26,435 1

Seq Scan on epics (cost=0.00..619.35 rows=26,435 width=12) (actual time=0.006..3.636 rows=26,435 loops=1)

84. 0.649 2.080 ↑ 1.0 2,851 1

Hash (cost=166.39..166.39 rows=2,851 width=8) (actual time=2.080..2.080 rows=2,851 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 144kB
85. 1.431 1.431 ↑ 1.0 2,851 1

Seq Scan on project_plans general_epic_plans (cost=0.00..166.39 rows=2,851 width=8) (actual time=0.008..1.431 rows=2,851 loops=1)

  • Filter: active
  • Rows Removed by Filter: 3188
86. 0.931 1.839 ↑ 1.0 5,812 1

Hash (cost=156.12..156.12 rows=5,812 width=8) (actual time=1.839..1.839 rows=5,812 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 292kB
87. 0.908 0.908 ↑ 1.0 5,812 1

Seq Scan on projects (cost=0.00..156.12 rows=5,812 width=8) (actual time=0.006..0.908 rows=5,812 loops=1)

88. 1.934 3.395 ↑ 1.0 4,221 1

Hash (cost=91.21..91.21 rows=4,221 width=40) (actual time=3.394..3.395 rows=4,221 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 370kB
89. 1.461 1.461 ↑ 1.0 4,221 1

Seq Scan on staff_activities_with_dates sa (cost=0.00..91.21 rows=4,221 width=40) (actual time=0.019..1.461 rows=4,221 loops=1)

90. 0.054 0.134 ↑ 1.0 354 1

Hash (cost=14.54..14.54 rows=354 width=9) (actual time=0.134..0.134 rows=354 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
91. 0.080 0.080 ↑ 1.0 354 1

Seq Scan on accounts accounts_1 (cost=0.00..14.54 rows=354 width=9) (actual time=0.003..0.080 rows=354 loops=1)

92. 15.793 413.840 ↑ 2.3 28,906 1

Subquery Scan on *SELECT* 2_1 (cost=2,320.78..436,717.88 rows=67,557 width=136) (actual time=38.932..413.840 rows=28,906 loops=1)

93. 251.404 398.047 ↑ 2.3 28,906 1

Hash Anti Join (cost=2,320.78..435,873.42 rows=67,557 width=143) (actual time=38.928..398.047 rows=28,906 loops=1)

  • Hash Cond: ((sa_1.account_id = non_working_intervals_by_dates_1.account_id) AND (sa_1.user_id = non_working_intervals_by_dates_1.user_id))
  • Join Filter: (generate_series_3.generate_series = non_working_intervals_by_dates_1.date)
  • Rows Removed by Join Filter: 1153172
94. 26.291 111.231 ↑ 2.6 29,394 1

Hash Join (cost=143.98..429,184.39 rows=77,078 width=64) (actual time=3.417..111.231 rows=29,394 loops=1)

  • Hash Cond: (vacations_1.staff_membership_id = sa_1.staff_membership_id)
  • Join Filter: ((generate_series_3.generate_series >= sa_1.start_date) AND (generate_series_3.generate_series <= sa_1.end_date))
  • Rows Removed by Join Filter: 10924
95. 12.089 81.636 ↑ 17.5 31,132 1

Nested Loop (cost=0.01..414,548.93 rows=544,800 width=44) (actual time=0.042..81.636 rows=31,132 loops=1)

96. 4.171 4.171 ↑ 1.0 21,792 1

Seq Scan on vacations vacations_1 (cost=0.00..500.92 rows=21,792 width=44) (actual time=0.019..4.171 rows=21,792 loops=1)

97. 65.376 65.376 ↑ 25.0 1 21,792

Function Scan on generate_series generate_series_3 (cost=0.01..18.76 rows=25 width=8) (actual time=0.002..0.003 rows=1 loops=21,792)

  • Filter: (date_part('dow'::text, generate_series) = ANY ('{1,2,3,4,5}'::double precision[]))
  • Rows Removed by Filter: 0
98. 1.851 3.304 ↑ 1.0 4,221 1

Hash (cost=91.21..91.21 rows=4,221 width=36) (actual time=3.303..3.304 rows=4,221 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 350kB
99. 1.453 1.453 ↑ 1.0 4,221 1

Seq Scan on staff_activities_with_dates sa_1 (cost=0.00..91.21 rows=4,221 width=36) (actual time=0.010..1.453 rows=4,221 loops=1)

100. 18.415 35.412 ↑ 1.0 58,975 1

Hash (cost=1,281.12..1,281.12 rows=59,712 width=12) (actual time=35.412..35.412 rows=58,975 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 3047kB
101. 16.997 16.997 ↑ 1.0 59,712 1

Seq Scan on non_working_intervals_by_dates non_working_intervals_by_dates_1 (cost=0.00..1,281.12 rows=59,712 width=12) (actual time=0.009..16.997 rows=59,712 loops=1)

102. 0.005 0.121 ↑ 9.8 12 1

Hash (cost=17.20..17.20 rows=118 width=4) (actual time=0.120..0.121 rows=12 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
103. 0.116 0.116 ↑ 9.8 12 1

Seq Scan on accounts (cost=0.00..17.20 rows=118 width=4) (actual time=0.015..0.116 rows=12 loops=1)

  • Filter: ((suspended_at)::date >= CURRENT_DATE)
  • Rows Removed by Filter: 342
104. 526.414 929.650 ↓ 4.1 1,115,238 1

Sort (cost=46,830.92..47,512.59 rows=272,669 width=44) (actual time=801.683..929.650 rows=1,115,238 loops=1)

  • Sort Key: ""*SELECT* 1"".project_id, ""*SELECT* 1"".activity_id
  • Sort Method: quicksort Memory: 32838kB
105. 44.089 403.236 ↑ 1.0 263,033 1

Append (cost=300.88..22,213.28 rows=272,669 width=44) (actual time=2.872..403.236 rows=263,033 loops=1)

106. 0.137 22.454 ↓ 9.7 474 1

Subquery Scan on *SELECT* 1 (cost=300.88..470.62 rows=49 width=44) (actual time=2.871..22.454 rows=474 loops=1)

107. 0.204 22.317 ↓ 9.7 474 1

Merge Join (cost=300.88..470.13 rows=49 width=612) (actual time=2.869..22.317 rows=474 loops=1)

  • Merge Cond: (clients.brand_id = brands.id)
108. 0.212 22.054 ↓ 9.7 474 1

Nested Loop (cost=294.80..1,671.71 rows=49 width=52) (actual time=2.807..22.054 rows=474 loops=1)

109. 0.009 1.887 ↓ 5.0 5 1

Merge Join (cost=294.38..294.67 rows=1 width=32) (actual time=1.866..1.887 rows=5 loops=1)

  • Merge Cond: (rate_cards.rateable_id = clients.brand_id)
110. 0.030 0.863 ↑ 28.8 4 1

WindowAgg (cost=108.61..111.49 rows=115 width=45) (actual time=0.843..0.863 rows=4 loops=1)

111. 0.052 0.833 ↑ 23.0 5 1

Sort (cost=108.61..108.90 rows=115 width=29) (actual time=0.832..0.833 rows=5 loops=1)

  • Sort Key: rate_cards.rateable_id, rate_cards.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 33kB
112. 0.781 0.781 ↑ 1.0 115 1

Seq Scan on rate_cards (cost=0.00..104.68 rows=115 width=29) (actual time=0.188..0.781 rows=115 loops=1)

  • Filter: ((rateable_type)::text = 'Brand'::text)
  • Rows Removed by Filter: 4739
113. 0.007 1.015 ↑ 1.0 5 1

Sort (cost=185.76..185.78 rows=5 width=8) (actual time=1.013..1.015 rows=5 loops=1)

  • Sort Key: clients.brand_id
  • Sort Method: quicksort Memory: 25kB
114. 0.009 1.008 ↑ 1.0 5 1

Nested Loop (cost=0.56..185.71 rows=5 width=8) (actual time=0.549..1.008 rows=5 loops=1)

115. 0.010 0.984 ↑ 1.0 5 1

Nested Loop (cost=0.28..184.13 rows=5 width=8) (actual time=0.541..0.984 rows=5 loops=1)

116. 0.954 0.954 ↑ 1.0 5 1

Seq Scan on pricing_models (cost=0.00..142.62 rows=5 width=4) (actual time=0.525..0.954 rows=5 loops=1)

  • Filter: ((rates_type)::text = 'brand'::text)
  • Rows Removed by Filter: 5805
117. 0.020 0.020 ↑ 1.0 1 5

Index Scan using projects_pkey on projects projects_2 (cost=0.28..8.30 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=5)

  • Index Cond: (id = pricing_models.project_id)
118. 0.015 0.015 ↑ 1.0 1 5

Index Scan using clients_pkey on clients (cost=0.28..0.32 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=5)

  • Index Cond: (id = projects_2.client_id)
119. 19.955 19.955 ↓ 1.9 95 5

Index Scan using index_rates_on_activity_id_and_rate_card_id on rates (cost=0.42..1,376.55 rows=49 width=28) (actual time=0.893..3.991 rows=95 loops=5)

  • Index Cond: (rate_card_id = rate_cards.id)
120. 0.032 0.059 ↑ 38.3 3 1

Sort (cost=6.09..6.37 rows=115 width=4) (actual time=0.058..0.059 rows=3 loops=1)

  • Sort Key: brands.id
  • Sort Method: quicksort Memory: 30kB
121. 0.027 0.027 ↑ 1.0 115 1

Seq Scan on brands (cost=0.00..2.15 rows=115 width=4) (actual time=0.008..0.027 rows=115 loops=1)

122. 20.660 111.922 ↓ 2.6 91,600 1

Subquery Scan on *SELECT* 2 (cost=583.00..5,484.31 rows=35,240 width=44) (actual time=18.186..111.922 rows=91,600 loops=1)

123. 58.817 91.262 ↓ 2.6 91,600 1

Hash Join (cost=583.00..5,131.91 rows=35,240 width=612) (actual time=18.184..91.262 rows=91,600 loops=1)

  • Hash Cond: (rates_1.rate_card_id = rate_cards_1.id)
124. 24.757 24.757 ↑ 1.0 174,437 1

Seq Scan on rates rates_1 (cost=0.00..3,542.37 rows=174,437 width=28) (actual time=0.013..24.757 rows=174,437 loops=1)

125. 0.264 7.688 ↑ 1.1 657 1

Hash (cost=574.00..574.00 rows=720 width=24) (actual time=7.688..7.688 rows=657 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 47kB
126. 0.257 7.424 ↑ 1.1 657 1

Hash Join (cost=378.98..574.00 rows=720 width=24) (actual time=4.648..7.424 rows=657 loops=1)

  • Hash Cond: (clients_1.office_id = offices.id)
127. 0.263 4.900 ↑ 1.0 623 1

Hash Join (cost=214.02..399.80 rows=623 width=8) (actual time=2.376..4.900 rows=623 loops=1)

  • Hash Cond: (projects_3.client_id = clients_1.id)
128. 1.341 3.601 ↑ 1.0 623 1

Hash Join (cost=150.41..334.56 rows=623 width=8) (actual time=1.334..3.601 rows=623 loops=1)

  • Hash Cond: (projects_3.id = pricing_models_1.project_id)
129. 0.946 0.946 ↑ 1.0 5,812 1

Seq Scan on projects projects_3 (cost=0.00..156.12 rows=5,812 width=8) (actual time=0.011..0.946 rows=5,812 loops=1)

130. 0.161 1.314 ↑ 1.0 623 1

Hash (cost=142.62..142.62 rows=623 width=4) (actual time=1.314..1.314 rows=623 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 30kB
131. 1.153 1.153 ↑ 1.0 623 1

Seq Scan on pricing_models pricing_models_1 (cost=0.00..142.62 rows=623 width=4) (actual time=0.020..1.153 rows=623 loops=1)

  • Filter: ((rates_type)::text = 'office'::text)
  • Rows Removed by Filter: 5187
132. 0.492 1.036 ↑ 1.0 1,849 1

Hash (cost=40.49..40.49 rows=1,849 width=8) (actual time=1.035..1.036 rows=1,849 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 89kB
133. 0.544 0.544 ↑ 1.0 1,849 1

Seq Scan on clients clients_1 (cost=0.00..40.49 rows=1,849 width=8) (actual time=0.009..0.544 rows=1,849 loops=1)

134. 0.182 2.267 ↑ 1.1 450 1

Hash (cost=158.85..158.85 rows=489 width=28) (actual time=2.267..2.267 rows=450 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 35kB
135. 0.181 2.085 ↑ 1.1 450 1

Hash Join (cost=140.44..158.85 rows=489 width=28) (actual time=1.327..2.085 rows=450 loops=1)

  • Hash Cond: (rate_cards_1.rateable_id = offices.id)
136. 0.532 1.685 ↑ 1.0 489 1

WindowAgg (cost=126.52..138.74 rows=489 width=45) (actual time=1.101..1.685 rows=489 loops=1)

137. 0.265 1.153 ↑ 1.0 489 1

Sort (cost=126.52..127.74 rows=489 width=29) (actual time=1.093..1.153 rows=489 loops=1)

  • Sort Key: rate_cards_1.rateable_id, rate_cards_1.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 63kB
138. 0.888 0.888 ↑ 1.0 489 1

Seq Scan on rate_cards rate_cards_1 (cost=0.00..104.68 rows=489 width=29) (actual time=0.171..0.888 rows=489 loops=1)

  • Filter: ((rateable_type)::text = 'Office'::text)
  • Rows Removed by Filter: 4365
139. 0.128 0.219 ↑ 1.0 441 1

Hash (cost=8.41..8.41 rows=441 width=4) (actual time=0.219..0.219 rows=441 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
140. 0.091 0.091 ↑ 1.0 441 1

Seq Scan on offices (cost=0.00..8.41 rows=441 width=4) (actual time=0.008..0.091 rows=441 loops=1)

141. 21.341 118.924 ↑ 2.2 94,593 1

Subquery Scan on *SELECT* 3 (cost=840.78..9,363.71 rows=205,419 width=44) (actual time=15.410..118.924 rows=94,593 loops=1)

142. 58.413 97.583 ↑ 2.2 94,593 1

Hash Join (cost=840.78..7,309.52 rows=205,419 width=612) (actual time=15.409..97.583 rows=94,593 loops=1)

  • Hash Cond: (rates_2.rate_card_id = rate_cards_2.id)
143. 23.813 23.813 ↑ 1.0 174,437 1

Seq Scan on rates rates_2 (cost=0.00..3,542.37 rows=174,437 width=28) (actual time=0.014..23.813 rows=174,437 loops=1)

144. 1.330 15.357 ↑ 1.0 4,004 1

Hash (cost=788.31..788.31 rows=4,197 width=24) (actual time=15.357..15.357 rows=4,004 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 299kB
145. 1.402 14.027 ↑ 1.0 4,004 1

Hash Join (cost=586.95..788.31 rows=4,197 width=24) (actual time=9.933..14.027 rows=4,004 loops=1)

  • Hash Cond: (projects_4.client_id = clients_2.id)
146. 1.532 5.885 ↑ 1.0 3,620 1

Hash Join (cost=228.77..380.91 rows=3,620 width=8) (actual time=3.183..5.885 rows=3,620 loops=1)

  • Hash Cond: (pricing_models_2.project_id = projects_4.id)
147. 1.273 1.273 ↑ 1.0 3,621 1

Seq Scan on pricing_models pricing_models_2 (cost=0.00..142.62 rows=3,621 width=4) (actual time=0.009..1.273 rows=3,621 loops=1)

  • Filter: ((rates_type)::text = 'client'::text)
  • Rows Removed by Filter: 2189
148. 1.442 3.080 ↑ 1.0 5,812 1

Hash (cost=156.12..156.12 rows=5,812 width=8) (actual time=3.080..3.080 rows=5,812 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 292kB
149. 1.638 1.638 ↑ 1.0 5,812 1

Seq Scan on projects projects_4 (cost=0.00..156.12 rows=5,812 width=8) (actual time=0.038..1.638 rows=5,812 loops=1)

150. 0.606 6.740 ↑ 1.0 1,820 1

Hash (cost=335.42..335.42 rows=1,821 width=28) (actual time=6.740..6.740 rows=1,820 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 123kB
151. 0.610 6.134 ↑ 1.0 1,820 1

Hash Join (cost=266.89..335.42 rows=1,821 width=28) (actual time=3.746..6.134 rows=1,820 loops=1)

  • Hash Cond: (rate_cards_2.rateable_id = clients_2.id)
152. 2.248 4.862 ↑ 1.0 1,821 1

WindowAgg (cost=203.29..248.81 rows=1,821 width=45) (actual time=3.065..4.862 rows=1,821 loops=1)

153. 1.662 2.614 ↑ 1.0 1,821 1

Sort (cost=203.29..207.84 rows=1,821 width=29) (actual time=2.428..2.614 rows=1,821 loops=1)

  • Sort Key: rate_cards_2.rateable_id, rate_cards_2.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 191kB
154. 0.952 0.952 ↑ 1.0 1,821 1

Seq Scan on rate_cards rate_cards_2 (cost=0.00..104.68 rows=1,821 width=29) (actual time=0.008..0.952 rows=1,821 loops=1)

  • Filter: ((rateable_type)::text = 'Client'::text)
  • Rows Removed by Filter: 3033
155. 0.360 0.662 ↑ 1.0 1,849 1

Hash (cost=40.49..40.49 rows=1,849 width=4) (actual time=0.662..0.662 rows=1,849 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 82kB
156. 0.302 0.302 ↑ 1.0 1,849 1

Seq Scan on clients clients_2 (cost=0.00..40.49 rows=1,849 width=4) (actual time=0.010..0.302 rows=1,849 loops=1)

157. 16.074 105.847 ↓ 2.4 76,366 1

Subquery Scan on *SELECT* 4 (cost=695.56..5,531.29 rows=31,961 width=44) (actual time=18.264..105.847 rows=76,366 loops=1)

158. 49.492 89.773 ↓ 2.4 76,366 1

Hash Join (cost=695.56..5,211.68 rows=31,961 width=612) (actual time=18.263..89.773 rows=76,366 loops=1)

  • Hash Cond: (rates_3.rate_card_id = rate_cards_3.id)
159. 22.071 22.071 ↑ 1.0 174,437 1

Seq Scan on rates rates_3 (cost=0.00..3,542.37 rows=174,437 width=28) (actual time=0.012..22.071 rows=174,437 loops=1)

160. 0.600 18.210 ↓ 2.4 1,591 1

Hash (cost=687.40..687.40 rows=653 width=24) (actual time=18.210..18.210 rows=1,591 loops=1)

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 110kB
161. 8.084 17.610 ↓ 2.4 1,591 1

Hash Join (cost=502.95..687.40 rows=653 width=24) (actual time=15.156..17.610 rows=1,591 loops=1)

  • Hash Cond: (projects_5.id = pricing_models_3.project_id)
162. 0.905 0.905 ↑ 1.0 5,812 1

Seq Scan on projects projects_5 (cost=0.00..156.12 rows=5,812 width=4) (actual time=0.007..0.905 rows=5,812 loops=1)

163. 0.596 8.621 ↓ 2.4 1,591 1

Hash (cost=494.79..494.79 rows=653 width=24) (actual time=8.621..8.621 rows=1,591 loops=1)

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 110kB
164. 0.842 8.025 ↓ 2.4 1,591 1

Hash Join (cost=403.40..494.79 rows=653 width=24) (actual time=4.271..8.025 rows=1,591 loops=1)

  • Hash Cond: (rate_cards_3.rateable_id = pricing_models_3.id)
165. 2.675 5.415 ↑ 1.0 2,429 1

WindowAgg (cost=241.26..301.98 rows=2,429 width=45) (actual time=2.487..5.415 rows=2,429 loops=1)

166. 1.566 2.740 ↑ 1.0 2,429 1

Sort (cost=241.26..247.33 rows=2,429 width=29) (actual time=2.461..2.740 rows=2,429 loops=1)

  • Sort Key: rate_cards_3.rateable_id, rate_cards_3.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 286kB
167. 1.174 1.174 ↑ 1.0 2,429 1

Seq Scan on rate_cards rate_cards_3 (cost=0.00..104.68 rows=2,429 width=29) (actual time=0.010..1.174 rows=2,429 loops=1)

  • Filter: ((rateable_type)::text = 'PricingModel'::text)
  • Rows Removed by Filter: 2425
168. 0.427 1.768 ↑ 1.0 1,561 1

Hash (cost=142.62..142.62 rows=1,561 width=8) (actual time=1.768..1.768 rows=1,561 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 77kB
169. 1.341 1.341 ↑ 1.0 1,561 1

Seq Scan on pricing_models pricing_models_3 (cost=0.00..142.62 rows=1,561 width=8) (actual time=0.025..1.341 rows=1,561 loops=1)

  • Filter: ((rates_type)::text = 'custom'::text)
  • Rows Removed by Filter: 4249
170. 65.942 66.076 ↓ 1,993.3 609,953 1

Sort (cost=22.77..23.53 rows=306 width=26) (actual time=0.391..66.076 rows=609,953 loops=1)

  • Sort Key: discounts.project_id
  • Sort Method: quicksort Memory: 53kB
171. 0.134 0.134 ↓ 1.2 359 1

Seq Scan on discounts (cost=0.00..10.13 rows=306 width=26) (actual time=0.025..0.134 rows=359 loops=1)

  • Filter: (((discountable_type)::text = 'User'::text) OR ((discountable_type)::text = 'Epic'::text))
  • Rows Removed by Filter: 50
172. 3,769.942 3,770.839 ↓ 12,841.5 39,140,740 1

Sort (cost=244.86..252.48 rows=3,048 width=24) (actual time=4.458..3,770.839 rows=39,140,740 loops=1)

  • Sort Key: exchange_rates_by_months.account_id, exchange_rates_by_months.currency
  • Sort Method: quicksort Memory: 335kB
173. 0.897 0.897 ↑ 1.0 3,048 1

Seq Scan on exchange_rates_by_months (cost=0.00..68.48 rows=3,048 width=24) (actual time=0.022..0.897 rows=3,048 loops=1)

174. 3,326.150 3,327.017 ↓ 11,405.1 34,762,629 1

Sort (cost=244.86..252.48 rows=3,048 width=24) (actual time=2.092..3,327.017 rows=34,762,629 loops=1)

  • Sort Key: cost_exchange_rates.account_id, cost_exchange_rates.currency
  • Sort Method: quicksort Memory: 335kB
175. 0.867 0.867 ↑ 1.0 3,048 1

Seq Scan on exchange_rates_by_months cost_exchange_rates (cost=0.00..68.48 rows=3,048 width=24) (actual time=0.020..0.867 rows=3,048 loops=1)

Planning time : 12.399 ms
Execution time : 53,472.362 ms