explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ixfc : Optimization for: plan #4xF

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 272.628 31,158.454 ↓ 9.2 579,765 1

Hash Left Join (cost=1,089,721.07..14,459,295.70 rows=63,201 width=140) (actual time=3,737.373..31,158.454 rows=579,765 loops=1)

  • Hash 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: 573,282
2. 4,086.442 30,885.670 ↓ 9.2 579,690 1

Hash Left Join (cost=1,089,707.11..14,453,704.24 rows=63,201 width=148) (actual time=3,737.195..30,885.670 rows=579,690 loops=1)

  • Hash Cond: ((projects.account_id = cost_exchange_rates.account_id) AND ((staff_memberships_1.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: 34,220,167
3. 4,090.494 26,798.081 ↓ 9.2 579,690 1

Hash Left Join (cost=1,089,592.91..14,393,002.84 rows=63,201 width=172) (actual time=3,736.018..26,798.081 rows=579,690 loops=1)

  • Hash 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: 34,220,167
4. 330.672 22,706.302 ↓ 9.2 579,690 1

Hash Join (cost=1,089,478.71..14,332,301.45 rows=63,201 width=164) (actual time=3,734.687..22,706.302 rows=579,690 loops=1)

  • Hash Cond: ((projects.id = ""*SELECT* 1"".project_id) AND ((COALESCE(""*SELECT* 1_1"".activity_id, staff_membership_activity_links.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: 208,764
5. 241.991 21,978.340 ↓ 9.3 771,563 1

Hash Join (cost=1,061,953.35..8,664,121.00 rows=82,617 width=136) (actual time=3,335.189..21,978.340 rows=771,563 loops=1)

  • Hash Cond: (projects.account_id = accounts.id)
6. 137.503 21,736.255 ↓ 4.1 1,009,568 1

Append (cost=1,061,934.68..8,660,965.41 rows=247,852 width=136) (actual time=3,335.086..21,736.255 rows=1,009,568 loops=1)

7. 754.447 21,350.158 ↓ 364.0 980,662 1

Hash Join (cost=1,061,934.68..8,147,679.08 rows=2,694 width=108) (actual time=3,335.086..21,350.158 rows=980,662 loops=1)

  • Hash Cond: (("*SELECT* 1_1".project_id = projects.id) AND ("*SELECT* 1_1".user_id = staff_memberships_1.user_id))
  • Join Filter: ((""*SELECT* 1_1"".date >= (COALESCE(staff_membership_activity_links.start_date, staff_memberships_1.joined_at))) AND (""*SELECT* 1_1"".date <= (COALESCE(lag((staff_membership_activity_links.start_date - 1), 1) OVER (?), staff_memberships_1.archived_at, '3000-01-01'::date))) AND ((((""*SELECT* 1_1"".vacation_user_id)::double precision) IS NULL) OR (((""*SELECT* 1_1"".vacation_hours)::double precision) < (COALESCE(staff_membership_activity_links.capacity, accounts_1.default_capacity))::double precision)))
  • Rows Removed by Join Filter: 272,495
8. 150.118 19,437.567 ↑ 1.1 1,100,806 1

Append (cost=1,058,917.37..8,089,122.71 rows=1,199,950 width=116) (actual time=2,161.690..19,437.567 rows=1,100,806 loops=1)

9. 148.698 4,958.617 ↑ 1.2 396,845 1

Result (cost=1,058,917.37..7,892,918.74 rows=495,989 width=116) (actual time=2,161.689..4,958.617 rows=396,845 loops=1)

10. 51.342 4,809.919 ↑ 1.2 396,845 1

Append (cost=1,058,917.37..7,886,718.88 rows=495,989 width=140) (actual time=2,161.686..4,809.919 rows=396,845 loops=1)

11. 73.692 4,423.689 ↑ 1.4 338,629 1

Subquery Scan on *SELECT* 1_1 (cost=1,058,917.37..7,821,758.58 rows=457,239 width=114) (actual time=2,161.685..4,423.689 rows=338,629 loops=1)

12. 2,164.285 4,349.997 ↑ 1.4 338,629 1

Hash Right Join (cost=1,058,917.37..7,814,899.99 rows=457,239 width=134) (actual time=2,161.683..4,349.997 rows=338,629 loops=1)

  • Hash Cond: ((staff_memberships.account_id = projects_1.account_id) AND (staff_memberships.user_id = plan_rows.user_id))
  • Join Filter: (generate_series.generate_series = ((generate_series_1.generate_series)::date))
  • Rows Removed by Join Filter: 14,110,732
13. 44.876 102.327 ↑ 17.8 32,266 1

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

  • Group Key: generate_series_1.generate_series, staff_memberships.user_id, staff_memberships.account_id
14. 13.284 57.451 ↑ 134.2 32,422 1

Hash Join (cost=138.05..493,700.50 rows=4,351,382 width=21) (actual time=2.223..57.451 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: 1,908
15. 17.579 42.054 ↑ 634.8 34,330 1

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

16. 2.683 2.683 ↑ 1.0 21,792 1

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

17. 21.792 21.792 ↑ 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.001 rows=2 loops=21,792)

18. 1.107 2.113 ↑ 1.0 4,002 1

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

  • Buckets: 4,096 Batches: 1 Memory Usage: 229kB
19. 1.006 1.006 ↑ 1.0 4,002 1

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

20. 136.663 2,083.385 ↑ 1.4 338,629 1

Hash (cost=514,844.46..514,844.46 rows=457,239 width=66) (actual time=2,083.384..2,083.385 rows=338,629 loops=1)

  • Buckets: 524,288 Batches: 1 Memory Usage: 38,679kB
21. 1,069.393 1,946.722 ↑ 1.4 338,629 1

Hash Anti Join (cost=464,677.72..514,844.46 rows=457,239 width=66) (actual time=667.322..1,946.722 rows=338,629 loops=1)

  • Hash Cond: ((projects_1.account_id = non_working_intervals_by_dates.account_id) AND (plan_rows.user_id = non_working_intervals_by_dates.user_id))
  • Join Filter: (generate_series.generate_series = non_working_intervals_by_dates.date)
  • Rows Removed by Join Filter: 11,449,923
22. 168.069 855.729 ↑ 1.7 346,275 1

Hash Right Join (cost=462,500.92..466,446.67 rows=579,175 width=66) (actual time=645.693..855.729 rows=346,275 loops=1)

  • Hash Cond: ((plan_rows_1.project_plan_id = project_plans.id) AND (((min(((plan_rows_1.uuid)::character varying)::text))::uuid) = plan_items.plan_row_uuid) AND (plan_rows_1.user_id = plan_rows.user_id))
  • Join Filter: (((plan_rows_1.epic_id = plan_rows.epic_id) OR (plan_rows.epic_id IS NULL)) AND ((generate_series.generate_series)::date >= (COALESCE(plan_roles.start_date, '1980-01-01'::date))) AND ((generate_series.generate_series)::date <= (COALESCE(lag((plan_roles.start_date - 1), 1) OVER (?), '3000-01-01'::date))))
  • Rows Removed by Join Filter: 3,247
23. 76.656 173.793 ↓ 8.9 44,428 1

HashAggregate (cost=8,529.07..8,603.63 rows=4,971 width=48) (actual time=126.818..173.793 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)
24. 30.059 97.137 ↑ 1.0 44,581 1

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

25. 26.550 67.078 ↑ 1.0 44,581 1

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

  • Sort Key: plan_roles.plan_row_uuid, plan_roles.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 5,023kB
26. 17.488 40.528 ↑ 1.0 44,581 1

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

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

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

28. 10.401 18.374 ↑ 1.0 48,106 1

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

  • Buckets: 65,536 Batches: 1 Memory Usage: 3,180kB
29. 7.973 7.973 ↑ 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.006..7.973 rows=48,106 loops=1)

30. 141.635 513.867 ↑ 1.7 346,275 1

Hash (cost=443,836.29..443,836.29 rows=579,175 width=70) (actual time=513.867..513.867 rows=346,275 loops=1)

  • Buckets: 1,048,576 Batches: 1 Memory Usage: 45,544kB
31. 79.060 372.232 ↑ 1.7 346,275 1

Nested Loop (cost=1,991.21..443,836.29 rows=579,175 width=70) (actual time=27.208..372.232 rows=346,275 loops=1)

32. 9.347 75.076 ↓ 1.2 27,262 1

Hash Join (cost=1,991.21..3,663.28 rows=23,167 width=70) (actual time=27.182..75.076 rows=27,262 loops=1)

  • Hash Cond: (project_plans.project_id = projects_1.id)
33. 12.517 63.260 ↓ 1.2 27,262 1

Hash Join (cost=1,762.44..3,373.65 rows=23,167 width=66) (actual time=24.651..63.260 rows=27,262 loops=1)

  • Hash Cond: (plan_items.plan_row_uuid = plan_rows.uuid)
34. 14.157 28.745 ↓ 1.1 29,797 1

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

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

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

  • Filter: (utilization > '0'::numeric)
  • Rows Removed by Filter: 264
36. 0.675 2.160 ↑ 1.0 2,851 1

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

  • Buckets: 4,096 Batches: 1 Memory Usage: 144kB
37. 1.485 1.485 ↑ 1.0 2,851 1

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

  • Filter: active
  • Rows Removed by Filter: 3,188
38. 11.309 21.998 ↑ 1.0 42,344 1

Hash (cost=1,030.06..1,030.06 rows=42,428 width=28) (actual time=21.998..21.998 rows=42,344 loops=1)

  • Buckets: 65,536 Batches: 1 Memory Usage: 2,816kB
39. 10.689 10.689 ↑ 1.0 42,344 1

Seq Scan on plan_rows (cost=0.00..1,030.06 rows=42,428 width=28) (actual time=0.014..10.689 rows=42,344 loops=1)

  • Filter: (user_id IS NOT NULL)
  • Rows Removed by Filter: 5,762
40. 1.284 2.469 ↑ 1.0 5,812 1

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

  • Buckets: 8,192 Batches: 1 Memory Usage: 292kB
41. 1.185 1.185 ↑ 1.0 5,812 1

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

42. 218.096 218.096 ↑ 1.9 13 27,262

Function Scan on generate_series (cost=0.01..18.76 rows=25 width=8) (actual time=0.003..0.008 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
43. 11.419 21.600 ↑ 1.0 58,975 1

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

  • Buckets: 65,536 Batches: 1 Memory Usage: 3,047kB
44. 10.181 10.181 ↑ 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.013..10.181 rows=59,712 loops=1)

45. 10.695 334.888 ↓ 1.5 58,216 1

Hash Join (cost=1,215.85..62,092.86 rows=38,750 width=114) (actual time=7.279..334.888 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
46. 12.903 85.534 ↑ 1.3 58,986 1

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

47. 1.646 29.536 ↑ 1.2 2,535 1

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

  • Hash Cond: (plan_items_1.project_plan_id = project_plans_1.id)
48. 13.000 26.238 ↓ 1.2 7,876 1

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

  • Hash Cond: (plan_items_1.plan_row_uuid = plan_rows_2.uuid)
49. 10.524 10.524 ↓ 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..10.524 rows=55,664 loops=1)

  • Filter: (utilization > '0'::numeric)
  • Rows Removed by Filter: 264
50. 1.090 2.714 ↓ 1.0 5,762 1

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

  • Buckets: 8,192 Batches: 1 Memory Usage: 366kB
51. 1.411 1.624 ↓ 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.251..1.624 rows=5,762 loops=1)

  • Recheck Cond: (user_id IS NULL)
  • Heap Blocks: exact=430
52. 0.213 0.213 ↓ 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.213..0.213 rows=5,762 loops=1)

  • Index Cond: (user_id IS NULL)
53. 0.523 1.652 ↑ 1.0 2,851 1

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

  • Buckets: 4,096 Batches: 1 Memory Usage: 144kB
54. 1.129 1.129 ↑ 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.008..1.129 rows=2,851 loops=1)

  • Filter: active
  • Rows Removed by Filter: 3,188
55. 43.095 43.095 ↑ 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.006..0.017 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
56. 1.278 2.715 ↑ 1.0 5,812 1

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

  • Buckets: 8,192 Batches: 1 Memory Usage: 314kB
57. 1.437 1.437 ↑ 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.437 rows=5,812 loops=1)

58.          

SubPlan (for Hash Join)

59. 58.986 235.944 ↓ 0.0 0 58,986

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

60. 58.986 58.986 ↑ 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.001 rows=1 loops=58,986)

  • Index Cond: (projects_1_1.client_id = id)
61. 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
62. 13,508.890 14,328.832 ↑ 1.0 703,961 1

Hash Right Join (cost=45,029.23..183,164.61 rows=703,961 width=116) (actual time=750.550..14,328.832 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: 63,215,381
63. 107.413 219.563 ↓ 8.9 44,428 1

HashAggregate (cost=8,529.07..8,603.63 rows=4,971 width=48) (actual time=146.078..219.563 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)
64. 34.416 112.150 ↑ 1.0 44,581 1

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

65. 29.616 77.734 ↑ 1.0 44,581 1

Sort (cost=6,077.00..6,188.46 rows=44,583 width=52) (actual time=71.121..77.734 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: 5,023kB
66. 19.850 48.118 ↑ 1.0 44,581 1

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

  • Hash Cond: (plan_roles_1.plan_row_uuid = plan_rows_3.uuid)
67. 5.111 5.111 ↑ 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.111 rows=44,581 loops=1)

68. 13.020 23.157 ↑ 1.0 48,106 1

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

  • Buckets: 65,536 Batches: 1 Memory Usage: 3,180kB
69. 10.137 10.137 ↑ 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.010..10.137 rows=48,106 loops=1)

70. 218.336 600.379 ↑ 1.0 703,961 1

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

  • Buckets: 1,048,576 Batches: 1 Memory Usage: 62,366kB
71. 271.125 382.043 ↑ 1.0 703,961 1

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

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

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

73. 5.314 16.786 ↑ 1.0 26,435 1

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

  • Buckets: 32,768 Batches: 1 Memory Usage: 1,381kB
74. 7.343 11.472 ↑ 1.0 26,435 1

Hash Left Join (cost=202.03..1,496.14 rows=26,435 width=16) (actual time=1.687..11.472 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: 11,144
75. 2.486 2.486 ↑ 1.0 26,435 1

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

76. 0.488 1.643 ↑ 1.0 2,851 1

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

  • Buckets: 4,096 Batches: 1 Memory Usage: 144kB
77. 1.155 1.155 ↑ 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.007..1.155 rows=2,851 loops=1)

  • Filter: active
  • Rows Removed by Filter: 3,188
78. 745.882 1,158.144 ↓ 27.2 1,899,868 1

Hash (cost=1,970.92..1,970.92 rows=69,760 width=49) (actual time=1,158.144..1,158.144 rows=1,899,868 loops=1)

  • Buckets: 2,097,152 (originally 131072) Batches: 1 (originally 1) Memory Usage: 179,638kB
79. 397.041 412.262 ↓ 27.2 1,899,868 1

Hash Join (cost=1,015.49..1,970.92 rows=69,760 width=49) (actual time=13.972..412.262 rows=1,899,868 loops=1)

  • Hash Cond: (projects.account_id = accounts_1.id)
80. 1.285 1.285 ↑ 1.0 5,812 1

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

81. 1.212 13.936 ↑ 1.0 4,221 1

Hash (cost=962.37..962.37 rows=4,249 width=49) (actual time=13.936..13.936 rows=4,221 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 429kB
82. 1.170 12.724 ↑ 1.0 4,221 1

Hash Join (cost=866.11..962.37 rows=4,249 width=49) (actual time=10.514..12.724 rows=4,221 loops=1)

  • Hash Cond: (staff_memberships_1.account_id = accounts_1.id)
83. 0.757 11.440 ↑ 1.0 4,221 1

Unique (cost=847.14..889.63 rows=4,249 width=65) (actual time=10.394..11.440 rows=4,221 loops=1)

84. 2.743 10.683 ↑ 1.0 4,249 1

Sort (cost=847.14..857.76 rows=4,249 width=65) (actual time=10.393..10.683 rows=4,249 loops=1)

  • Sort Key: staff_memberships_1.account_id, staff_memberships_1.user_id, (COALESCE(staff_membership_activity_links.start_date, staff_memberships_1.joined_at)), (COALESCE(lag((staff_membership_activity_links.start_date - 1), 1) OVER (?), staff_memberships_1.archived_at, '3000-01-01'::date)) DESC
  • Sort Method: quicksort Memory: 790kB
85. 2.877 7.940 ↑ 1.0 4,249 1

WindowAgg (cost=484.85..591.08 rows=4,249 width=65) (actual time=4.746..7.940 rows=4,249 loops=1)

86. 1.894 5.063 ↑ 1.0 4,249 1

Sort (cost=484.85..495.47 rows=4,249 width=56) (actual time=4.737..5.063 rows=4,249 loops=1)

  • Sort Key: staff_membership_activity_links.staff_membership_id, staff_membership_activity_links.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 790kB
87. 1.246 3.169 ↑ 1.0 4,249 1

Hash Join (cost=138.05..228.79 rows=4,249 width=56) (actual time=1.619..3.169 rows=4,249 loops=1)

  • Hash Cond: (staff_membership_activity_links.staff_membership_id = staff_memberships_1.id)
88. 0.342 0.342 ↑ 1.0 4,256 1

Seq Scan on staff_membership_activity_links (cost=0.00..79.56 rows=4,256 width=28) (actual time=0.005..0.342 rows=4,256 loops=1)

89. 0.854 1.581 ↑ 1.0 4,002 1

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

  • Buckets: 4,096 Batches: 1 Memory Usage: 276kB
90. 0.727 0.727 ↑ 1.0 4,002 1

Seq Scan on staff_memberships staff_memberships_1 (cost=0.00..88.02 rows=4,002 width=32) (actual time=0.005..0.727 rows=4,002 loops=1)

91. 0.051 0.114 ↑ 1.0 354 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 24kB
92. 0.063 0.063 ↑ 1.0 354 1

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

93. 8.314 248.594 ↑ 8.5 28,906 1

Subquery Scan on *SELECT* 2_1 (cost=424,372.25..512,020.13 rows=245,158 width=136) (actual time=88.894..248.594 rows=28,906 loops=1)

94. 137.997 240.280 ↑ 8.5 28,906 1

Hash Anti Join (cost=424,372.25..508,955.66 rows=245,158 width=143) (actual time=88.892..240.280 rows=28,906 loops=1)

  • Hash Cond: ((staff_memberships_2.account_id = non_working_intervals_by_dates_1.account_id) AND (staff_memberships_2.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: 1,153,172
95. 17.255 82.030 ↑ 9.5 29,394 1

Hash Join (cost=422,195.45..490,256.83 rows=280,181 width=64) (actual time=68.535..82.030 rows=29,394 loops=1)

  • Hash Cond: (staff_memberships_2.id = vacations_1.staff_membership_id)
  • Join Filter: ((generate_series_3.generate_series >= (COALESCE(staff_membership_activity_links_1.start_date, staff_memberships_2.joined_at))) AND (generate_series_3.generate_series <= (COALESCE(lag((staff_membership_activity_links_1.start_date - 1), 1) OVER (?), staff_memberships_2.archived_at, '3000-01-01'::date))))
  • Rows Removed by Join Filter: 10,924
96. 0.859 12.700 ↑ 1.0 4,221 1

Unique (cost=836.52..879.01 rows=4,249 width=65) (actual time=11.509..12.700 rows=4,221 loops=1)

97. 3.207 11.841 ↑ 1.0 4,249 1

Sort (cost=836.52..847.14 rows=4,249 width=65) (actual time=11.509..11.841 rows=4,249 loops=1)

  • Sort Key: staff_memberships_2.account_id, staff_memberships_2.user_id, (COALESCE(staff_membership_activity_links_1.start_date, staff_memberships_2.joined_at)), (COALESCE(lag((staff_membership_activity_links_1.start_date - 1), 1) OVER (?), staff_memberships_2.archived_at, '3000-01-01'::date)) DESC
  • Sort Method: quicksort Memory: 592kB
98. 3.191 8.634 ↑ 1.0 4,249 1

WindowAgg (cost=484.85..580.45 rows=4,249 width=65) (actual time=5.086..8.634 rows=4,249 loops=1)

99. 2.003 5.443 ↑ 1.0 4,249 1

Sort (cost=484.85..495.47 rows=4,249 width=44) (actual time=5.078..5.443 rows=4,249 loops=1)

  • Sort Key: staff_membership_activity_links_1.staff_membership_id, staff_membership_activity_links_1.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 561kB
100. 1.371 3.440 ↑ 1.0 4,249 1

Hash Join (cost=138.05..228.79 rows=4,249 width=44) (actual time=1.685..3.440 rows=4,249 loops=1)

  • Hash Cond: (staff_membership_activity_links_1.staff_membership_id = staff_memberships_2.id)
101. 0.407 0.407 ↑ 1.0 4,256 1

Seq Scan on staff_membership_activity_links staff_membership_activity_links_1 (cost=0.00..79.56 rows=4,256 width=20) (actual time=0.012..0.407 rows=4,256 loops=1)

102. 0.893 1.662 ↑ 1.0 4,002 1

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

  • Buckets: 4,096 Batches: 1 Memory Usage: 245kB
103. 0.769 0.769 ↑ 1.0 4,002 1

Seq Scan on staff_memberships staff_memberships_2 (cost=0.00..88.02 rows=4,002 width=24) (actual time=0.006..0.769 rows=4,002 loops=1)

104. 9.022 52.075 ↑ 17.5 31,132 1

Hash (cost=414,548.93..414,548.93 rows=544,800 width=44) (actual time=52.075..52.075 rows=31,132 loops=1)

  • Buckets: 1,048,576 Batches: 1 Memory Usage: 10,776kB
105. 19.128 43.053 ↑ 17.5 31,132 1

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

106. 2.133 2.133 ↑ 1.0 21,792 1

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

107. 21.792 21.792 ↑ 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.001..0.001 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
108. 10.545 20.253 ↑ 1.0 58,975 1

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

  • Buckets: 65,536 Batches: 1 Memory Usage: 3,047kB
109. 9.708 9.708 ↑ 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.010..9.708 rows=59,712 loops=1)

110. 0.005 0.094 ↑ 9.8 12 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
111. 0.089 0.089 ↑ 9.8 12 1

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

  • Filter: ((suspended_at)::date >= CURRENT_DATE)
  • Rows Removed by Filter: 342
112. 111.164 397.290 ↑ 1.0 263,033 1

Hash (cost=23,435.32..23,435.32 rows=272,669 width=44) (actual time=397.290..397.290 rows=263,033 loops=1)

  • Buckets: 524,288 Batches: 1 Memory Usage: 24,593kB
113. 31.892 286.126 ↑ 1.0 263,033 1

Append (cost=109.73..23,435.32 rows=272,669 width=44) (actual time=2.065..286.126 rows=263,033 loops=1)

114. 0.106 15.947 ↓ 9.7 474 1

Subquery Scan on *SELECT* 1 (cost=109.73..1,692.67 rows=49 width=44) (actual time=2.064..15.947 rows=474 loops=1)

115. 0.134 15.841 ↓ 9.7 474 1

Nested Loop (cost=109.73..1,692.18 rows=49 width=612) (actual time=2.062..15.841 rows=474 loops=1)

116. 0.129 15.233 ↓ 9.7 474 1

Nested Loop (cost=109.59..1,684.02 rows=49 width=52) (actual time=2.054..15.233 rows=474 loops=1)

117. 0.063 1.649 ↓ 5.0 5 1

Nested Loop (cost=109.17..306.98 rows=1 width=32) (actual time=1.415..1.649 rows=5 loops=1)

  • Join Filter: (clients.brand_id = rate_cards.rateable_id)
  • Rows Removed by Join Filter: 570
118. 0.115 0.781 ↑ 1.0 115 1

WindowAgg (cost=108.61..111.49 rows=115 width=45) (actual time=0.669..0.781 rows=115 loops=1)

119. 0.083 0.666 ↑ 1.0 115 1

Sort (cost=108.61..108.90 rows=115 width=29) (actual time=0.655..0.666 rows=115 loops=1)

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

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

  • Filter: ((rateable_type)::text = 'Brand'::text)
  • Rows Removed by Filter: 4,739
121. 0.076 0.805 ↑ 1.0 5 115

Materialize (cost=0.56..185.73 rows=5 width=8) (actual time=0.003..0.007 rows=5 loops=115)

122. 0.008 0.729 ↑ 1.0 5 1

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

123. 0.007 0.711 ↑ 1.0 5 1

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

124. 0.684 0.684 ↑ 1.0 5 1

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

  • Filter: ((rates_type)::text = 'brand'::text)
  • Rows Removed by Filter: 5,805
125. 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)
126. 0.010 0.010 ↑ 1.0 1 5

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

  • Index Cond: (id = projects_2.client_id)
127. 13.455 13.455 ↓ 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.651..2.691 rows=95 loops=5)

  • Index Cond: (rate_card_id = rate_cards.id)
128. 0.474 0.474 ↑ 1.0 1 474

Index Only Scan using brands_pkey on brands (cost=0.14..0.17 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=474)

  • Index Cond: (id = clients.brand_id)
  • Heap Fetches: 474
129. 15.247 79.798 ↓ 2.6 91,600 1

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

130. 40.604 64.551 ↓ 2.6 91,600 1

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

  • Hash Cond: (rates_1.rate_card_id = rate_cards_1.id)
131. 17.817 17.817 ↑ 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.011..17.817 rows=174,437 loops=1)

132. 0.242 6.130 ↑ 1.1 657 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 47kB
133. 0.266 5.888 ↑ 1.1 657 1

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

  • Hash Cond: (clients_1.office_id = offices.id)
134. 0.245 4.085 ↑ 1.0 623 1

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

  • Hash Cond: (projects_3.client_id = clients_1.id)
135. 1.169 3.200 ↑ 1.0 623 1

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

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

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

137. 0.164 1.227 ↑ 1.0 623 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 30kB
138. 1.063 1.063 ↑ 1.0 623 1

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

  • Filter: ((rates_type)::text = 'office'::text)
  • Rows Removed by Filter: 5,187
139. 0.303 0.640 ↑ 1.0 1,849 1

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

  • Buckets: 2,048 Batches: 1 Memory Usage: 89kB
140. 0.337 0.337 ↑ 1.0 1,849 1

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

141. 0.115 1.537 ↑ 1.1 450 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 35kB
142. 0.122 1.422 ↑ 1.1 450 1

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

  • Hash Cond: (rate_cards_1.rateable_id = offices.id)
143. 0.345 1.125 ↑ 1.0 489 1

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

144. 0.168 0.780 ↑ 1.0 489 1

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

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

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

  • Filter: ((rateable_type)::text = 'Office'::text)
  • Rows Removed by Filter: 4,365
146. 0.096 0.175 ↑ 1.0 441 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 24kB
147. 0.079 0.079 ↑ 1.0 441 1

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

148. 15.750 86.138 ↑ 2.2 94,593 1

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

149. 42.587 70.388 ↑ 2.2 94,593 1

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

  • Hash Cond: (rates_2.rate_card_id = rate_cards_2.id)
150. 17.567 17.567 ↑ 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.009..17.567 rows=174,437 loops=1)

151. 0.902 10.234 ↑ 1.0 4,004 1

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

  • Buckets: 8,192 Batches: 1 Memory Usage: 299kB
152. 1.011 9.332 ↑ 1.0 4,004 1

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

  • Hash Cond: (projects_4.client_id = clients_2.id)
153. 1.045 4.129 ↑ 1.0 3,620 1

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

  • Hash Cond: (pricing_models_2.project_id = projects_4.id)
154. 0.975 0.975 ↑ 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.007..0.975 rows=3,621 loops=1)

  • Filter: ((rates_type)::text = 'client'::text)
  • Rows Removed by Filter: 2,189
155. 0.892 2.109 ↑ 1.0 5,812 1

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

  • Buckets: 8,192 Batches: 1 Memory Usage: 292kB
156. 1.217 1.217 ↑ 1.0 5,812 1

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

157. 0.473 4.192 ↑ 1.0 1,820 1

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

  • Buckets: 2,048 Batches: 1 Memory Usage: 123kB
158. 0.490 3.719 ↑ 1.0 1,820 1

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

  • Hash Cond: (rate_cards_2.rateable_id = clients_2.id)
159. 1.366 2.716 ↑ 1.0 1,821 1

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

160. 0.670 1.350 ↑ 1.0 1,821 1

Sort (cost=203.29..207.84 rows=1,821 width=29) (actual time=1.212..1.350 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
161. 0.680 0.680 ↑ 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.006..0.680 rows=1,821 loops=1)

  • Filter: ((rateable_type)::text = 'Client'::text)
  • Rows Removed by Filter: 3,033
162. 0.296 0.513 ↑ 1.0 1,849 1

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

  • Buckets: 2,048 Batches: 1 Memory Usage: 82kB
163. 0.217 0.217 ↑ 1.0 1,849 1

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

164. 11.593 72.351 ↓ 2.4 76,366 1

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

165. 35.771 60.758 ↓ 2.4 76,366 1

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

  • Hash Cond: (rates_3.rate_card_id = rate_cards_3.id)
166. 17.658 17.658 ↑ 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.009..17.658 rows=174,437 loops=1)

167. 0.470 7.329 ↓ 2.4 1,591 1

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

  • Buckets: 2,048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 110kB
168. 1.229 6.859 ↓ 2.4 1,591 1

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

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

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

170. 0.322 4.873 ↓ 2.4 1,591 1

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

  • Buckets: 2,048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 110kB
171. 0.411 4.551 ↓ 2.4 1,591 1

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

  • Hash Cond: (rate_cards_3.rateable_id = pricing_models_3.id)
172. 1.435 2.984 ↑ 1.0 2,429 1

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

173. 0.863 1.549 ↑ 1.0 2,429 1

Sort (cost=241.26..247.33 rows=2,429 width=29) (actual time=1.400..1.549 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
174. 0.686 0.686 ↑ 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.007..0.686 rows=2,429 loops=1)

  • Filter: ((rateable_type)::text = 'PricingModel'::text)
  • Rows Removed by Filter: 2,425
175. 0.254 1.156 ↑ 1.0 1,561 1

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

  • Buckets: 2,048 Batches: 1 Memory Usage: 77kB
176. 0.902 0.902 ↑ 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.007..0.902 rows=1,561 loops=1)

  • Filter: ((rates_type)::text = 'custom'::text)
  • Rows Removed by Filter: 4,249
177. 0.696 1.285 ↑ 1.0 3,048 1

Hash (cost=68.48..68.48 rows=3,048 width=24) (actual time=1.285..1.285 rows=3,048 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 199kB
178. 0.589 0.589 ↑ 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.012..0.589 rows=3,048 loops=1)

179. 0.639 1.147 ↑ 1.0 3,048 1

Hash (cost=68.48..68.48 rows=3,048 width=24) (actual time=1.147..1.147 rows=3,048 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 199kB
180. 0.508 0.508 ↑ 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.004..0.508 rows=3,048 loops=1)

181. 0.076 0.156 ↓ 1.2 359 1

Hash (cost=10.13..10.13 rows=306 width=26) (actual time=0.156..0.156 rows=359 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 28kB
182. 0.080 0.080 ↓ 1.2 359 1

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

  • Filter: (((discountable_type)::text = 'User'::text) OR ((discountable_type)::text = 'Epic'::text))
  • Rows Removed by Filter: 50
Planning time : 6.894 ms
Execution time : 31,267.913 ms