explain.depesz.com

PostgreSQL's explain analyze made readable

Result: VKK1 : w buffers

Settings
# exclusive inclusive rows x rows loops node
1. 51,033.527 92,044.157 ↓ 3.9 850,568 1

Hash Left Join (cost=1,091,416.22..24,764,621.75 rows=216,456 width=188) (actual time=2,701.972..92,044.157 rows=850,568 loops=1)

  • Hash 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: 238662
  • Buffers: shared hit=11841064 read=4901
2. 404.537 40,595.647 ↓ 3.9 850,568 1

Hash Join (cost=1,064,036.01..9,831,730.05 rows=216,456 width=136) (actual time=2,283.731..40,595.647 rows=850,568 loops=1)

  • Hash Cond: (projects.account_id = accounts.id)
  • Buffers: shared hit=3067477 read=4901
3. 202.787 40,190.987 ↓ 1.7 1,116,748 1

Append (cost=1,064,017.34..9,823,492.72 rows=649,367 width=136) (actual time=2,283.600..40,190.987 rows=1,116,748 loops=1)

  • Buffers: shared hit=3067466 read=4901
4. 887.895 39,677.444 ↓ 2.7 1,087,842 1

Hash Join (cost=1,064,017.34..9,302,607.62 rows=404,209 width=108) (actual time=2,283.599..39,677.444 rows=1,087,842 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
  • Buffers: shared hit=3066414 read=4901
5. 720.812 38,789.395 ↑ 1.1 1,101,438 1

Hash Left Join (cost=1,063,998.38..9,284,260.78 rows=1,200,621 width=144) (actual time=2,269.610..38,789.395 rows=1,101,438 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: 259092
  • Buffers: shared hit=3066403 read=4901
6. 509.642 38,052.667 ↑ 1.1 1,101,438 1

Hash Join (cost=1,063,002.52..8,000,001.13 rows=1,200,621 width=120) (actual time=2,253.645..38,052.667 rows=1,101,438 loops=1)

  • Hash Cond: ("*SELECT* 1_1".project_id = projects.id)
  • Buffers: shared hit=3066318 read=4901
7. 185.570 37,541.023 ↑ 1.1 1,101,438 1

Append (cost=1,062,773.75..7,984,612.22 rows=1,200,621 width=116) (actual time=2,251.566..37,541.023 rows=1,101,438 loops=1)

  • Buffers: shared hit=3066220 read=4901
8. 218.915 23,547.023 ↑ 1.3 396,845 1

Result (cost=1,062,773.75..7,787,123.57 rows=496,660 width=116) (actual time=2,251.565..23,547.023 rows=396,845 loops=1)

  • Buffers: shared hit=3060516
9. 63.877 23,328.108 ↑ 1.3 396,845 1

Append (cost=1,062,773.75..7,780,915.32 rows=496,660 width=140) (actual time=2,251.561..23,328.108 rows=396,845 loops=1)

  • Buffers: shared hit=3060516
10. 95.679 4,549.419 ↑ 1.4 338,629 1

Subquery Scan on *SELECT* 1_1 (cost=1,062,773.75..7,714,854.75 rows=457,222 width=114) (actual time=2,251.560..4,549.419 rows=338,629 loops=1)

  • Buffers: shared hit=3454
11. 2,178.370 4,453.740 ↑ 1.4 338,629 1

Hash Right Join (cost=1,062,773.75..7,707,996.42 rows=457,222 width=134) (actual time=2,251.558..4,453.740 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: 14110732
  • Buffers: shared hit=3454
12. 44.416 101.622 ↑ 17.8 32,266 1

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

  • Group Key: generate_series_1.generate_series, staff_memberships.user_id, staff_memberships.account_id
  • Buffers: shared hit=331
13. 13.631 57.206 ↑ 134.2 32,422 1

Hash Join (cost=138.05..493,700.50 rows=4,351,382 width=21) (actual time=1.728..57.206 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
  • Buffers: shared hit=331
14. 17.450 41.911 ↑ 634.8 34,330 1

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

  • Buffers: shared hit=283
15. 2.669 2.669 ↑ 1.0 21,792 1

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

  • Buffers: shared hit=283
16. 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)

17. 0.851 1.664 ↑ 1.0 4,002 1

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

  • Buckets: 4096 Batches: 1 Memory Usage: 229kB
  • Buffers: shared hit=48
18. 0.813 0.813 ↑ 1.0 4,002 1

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

  • Buffers: shared hit=48
19. 142.509 2,173.748 ↑ 1.4 338,629 1

Hash (cost=518,701.10..518,701.10 rows=457,222 width=66) (actual time=2,173.748..2,173.748 rows=338,629 loops=1)

  • Buckets: 524288 Batches: 1 Memory Usage: 38679kB
  • Buffers: shared hit=3123
20. 1,109.508 2,031.239 ↑ 1.4 338,629 1

Hash Anti Join (cost=463,568.36..518,701.10 rows=457,222 width=66) (actual time=707.476..2,031.239 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: 11449923
  • Buffers: shared hit=3123
21. 170.198 896.726 ↑ 1.7 346,275 1

Hash Right Join (cost=461,391.56..465,319.85 rows=577,750 width=66) (actual time=682.422..896.726 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: 3247
  • Buffers: shared hit=2439
22. 79.807 190.733 ↓ 9.0 44,428 1

HashAggregate (cost=8,529.07..8,603.30 rows=4,949 width=48) (actual time=142.394..190.733 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)
  • Buffers: shared hit=989
23. 31.251 110.926 ↑ 1.0 44,581 1

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

  • Buffers: shared hit=989
24. 28.184 79.675 ↑ 1.0 44,581 1

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

  • Sort Key: plan_roles.plan_row_uuid, plan_roles.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 5023kB
  • Buffers: shared hit=989
25. 19.711 51.491 ↑ 1.0 44,581 1

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

  • Hash Cond: (plan_roles.plan_row_uuid = plan_rows_1.uuid)
  • Buffers: shared hit=989
26. 5.260 5.260 ↑ 1.0 44,581 1

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

  • Buffers: shared hit=440
27. 15.789 26.520 ↑ 1.0 48,106 1

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

  • Buckets: 65536 Batches: 1 Memory Usage: 3180kB
  • Buffers: shared hit=549
28. 10.731 10.731 ↑ 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.010..10.731 rows=48,106 loops=1)

  • Buffers: shared hit=549
29. 158.436 535.795 ↑ 1.7 346,275 1

Hash (cost=442,751.87..442,751.87 rows=577,750 width=70) (actual time=535.795..535.795 rows=346,275 loops=1)

  • Buckets: 1048576 Batches: 1 Memory Usage: 45544kB
  • Buffers: shared hit=1450
30. 86.669 377.359 ↑ 1.7 346,275 1

Nested Loop (cost=1,989.96..442,751.87 rows=577,750 width=70) (actual time=22.412..377.359 rows=346,275 loops=1)

  • Buffers: shared hit=1450
31. 9.848 72.594 ↓ 1.2 27,262 1

Hash Join (cost=1,989.96..3,661.86 rows=23,110 width=70) (actual time=22.387..72.594 rows=27,262 loops=1)

  • Hash Cond: (project_plans.project_id = projects_1.id)
  • Buffers: shared hit=1450
32. 12.523 60.795 ↓ 1.2 27,262 1

Hash Join (cost=1,761.19..3,372.38 rows=23,110 width=66) (actual time=20.406..60.795 rows=27,262 loops=1)

  • Hash Cond: (plan_items.plan_row_uuid = plan_rows.uuid)
  • Buffers: shared hit=1352
33. 15.302 29.780 ↓ 1.1 29,797 1

Hash Join (cost=202.03..1,744.27 rows=26,265 width=54) (actual time=1.634..29.780 rows=29,797 loops=1)

  • Hash Cond: (plan_items.project_plan_id = project_plans.id)
  • Buffers: shared hit=803
34. 12.877 12.877 ↓ 1.0 55,664 1

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

  • Filter: (utilization > '0'::numeric)
  • Rows Removed by Filter: 264
  • Buffers: shared hit=697
35. 0.477 1.601 ↑ 1.0 2,851 1

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

  • Buckets: 4096 Batches: 1 Memory Usage: 144kB
  • Buffers: shared hit=106
36. 1.124 1.124 ↑ 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.124 rows=2,851 loops=1)

  • Filter: active
  • Rows Removed by Filter: 3188
  • Buffers: shared hit=106
37. 9.572 18.492 ↓ 1.0 42,344 1

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

  • Buckets: 65536 Batches: 1 Memory Usage: 2816kB
  • Buffers: shared hit=549
38. 8.920 8.920 ↓ 1.0 42,344 1

Seq Scan on plan_rows (cost=0.00..1,030.06 rows=42,328 width=28) (actual time=0.007..8.920 rows=42,344 loops=1)

  • Filter: (user_id IS NOT NULL)
  • Rows Removed by Filter: 5762
  • Buffers: shared hit=549
39. 1.013 1.951 ↑ 1.0 5,812 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 292kB
  • Buffers: shared hit=98
40. 0.938 0.938 ↑ 1.0 5,812 1

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

  • Buffers: shared hit=98
41. 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
42. 12.974 25.005 ↑ 1.0 58,975 1

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

  • Buckets: 65536 Batches: 1 Memory Usage: 3047kB
  • Buffers: shared hit=684
43. 12.031 12.031 ↑ 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.020..12.031 rows=59,712 loops=1)

  • Buffers: shared hit=684
44. 54.771 18,714.812 ↓ 1.5 58,216 1

Hash Join (cost=1,059.11..63,182.89 rows=39,438 width=114) (actual time=8.327..18,714.812 rows=58,216 loops=1)

  • Hash Cond: (project_plans_1.project_id = project.id)
  • Join Filter: (NOT (SubPlan 1))
  • Rows Removed by Join Filter: 770
  • Buffers: shared hit=3057062
45. 23.863 135.061 ↑ 1.3 58,986 1

Nested Loop (cost=830.34..62,335.05 rows=78,875 width=58) (actual time=4.842..135.061 rows=58,986 loops=1)

  • Buffers: shared hit=1251
46. 2.965 37.683 ↑ 1.2 2,535 1

Hash Join (cost=830.34..2,390.04 rows=3,155 width=58) (actual time=4.823..37.683 rows=2,535 loops=1)

  • Hash Cond: (plan_items_1.project_plan_id = project_plans_1.id)
  • Buffers: shared hit=1251
47. 17.127 32.973 ↓ 1.2 7,876 1

Hash Join (cost=628.31..2,170.46 rows=6,682 width=54) (actual time=3.021..32.973 rows=7,876 loops=1)

  • Hash Cond: (plan_items_1.plan_row_uuid = plan_rows_2.uuid)
  • Buffers: shared hit=1145
48. 12.898 12.898 ↓ 1.0 55,664 1

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

  • Filter: (utilization > '0'::numeric)
  • Rows Removed by Filter: 264
  • Buffers: shared hit=697
49. 1.264 2.948 ↑ 1.0 5,762 1

Hash (cost=556.08..556.08 rows=5,778 width=24) (actual time=2.948..2.948 rows=5,762 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 366kB
  • Buffers: shared hit=448
50. 1.684 1.684 ↑ 1.0 5,762 1

Index Scan using index_plan_rows_on_user_id on plan_rows plan_rows_2 (cost=0.29..556.08 rows=5,778 width=24) (actual time=0.027..1.684 rows=5,762 loops=1)

  • Index Cond: (user_id IS NULL)
  • Buffers: shared hit=448
51. 0.549 1.745 ↑ 1.0 2,851 1

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

  • Buckets: 4096 Batches: 1 Memory Usage: 144kB
  • Buffers: shared hit=106
52. 1.196 1.196 ↑ 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.011..1.196 rows=2,851 loops=1)

  • Filter: active
  • Rows Removed by Filter: 3188
  • Buffers: shared hit=106
53. 73.515 73.515 ↑ 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.029 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
54. 1.598 3.376 ↑ 1.0 5,812 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 314kB
  • Buffers: shared hit=98
55. 1.778 1.778 ↑ 1.0 5,812 1

Seq Scan on projects project (cost=0.00..156.12 rows=5,812 width=12) (actual time=0.015..1.778 rows=5,812 loops=1)

  • Buffers: shared hit=98
56.          

SubPlan (for Hash Join)

57. 58.986 18,521.604 ↓ 0.0 0 58,986

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

  • Join Filter: (non_working_intervals_by_dates_2.office_id = clients_3.office_id)
  • Rows Removed by Join Filter: 3
  • Buffers: shared hit=3055713
58. 117.972 117.972 ↑ 1.0 1 58,986

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

  • Index Cond: (project.client_id = id)
  • Buffers: shared hit=177008
59. 18,344.646 18,344.646 ↑ 4.0 3 58,986

Index Scan using non_working_intervals_by_dates_idx on non_working_intervals_by_dates non_working_intervals_by_dates_2 (cost=0.41..42.12 rows=12 width=4) (actual time=0.301..0.311 rows=3 loops=58,986)

  • Index Cond: ((project.account_id = account_id) AND (generate_series_2.generate_series = date))
  • Buffers: shared hit=2878705
60. 12,945.707 13,808.430 ↓ 1.0 704,593 1

Hash Right Join (cost=45,029.23..184,445.93 rows=703,961 width=116) (actual time=790.551..13,808.430 rows=704,593 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 = active_plan.id))))
  • Rows Removed by Join Filter: 62978265
  • Buffers: shared hit=5704 read=4901
61. 109.245 211.283 ↓ 9.0 44,428 1

HashAggregate (cost=8,529.07..8,603.30 rows=4,949 width=48) (actual time=133.917..211.283 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)
  • Buffers: shared hit=989
62. 31.667 102.038 ↑ 1.0 44,581 1

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

  • Buffers: shared hit=989
63. 27.230 70.371 ↑ 1.0 44,581 1

Sort (cost=6,077.00..6,188.46 rows=44,583 width=52) (actual time=63.951..70.371 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
  • Buffers: shared hit=989
64. 18.514 43.141 ↑ 1.0 44,581 1

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

  • Hash Cond: (plan_roles_1.plan_row_uuid = plan_rows_3.uuid)
  • Buffers: shared hit=989
65. 4.722 4.722 ↑ 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.012..4.722 rows=44,581 loops=1)

  • Buffers: shared hit=440
66. 11.405 19.905 ↑ 1.0 48,106 1

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

  • Buckets: 65536 Batches: 1 Memory Usage: 3180kB
  • Buffers: shared hit=549
67. 8.500 8.500 ↑ 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.008..8.500 rows=48,106 loops=1)

  • Buffers: shared hit=549
68. 216.542 651.440 ↑ 1.0 703,961 1

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

  • Buckets: 1048576 Batches: 1 Memory Usage: 61640kB
  • Buffers: shared hit=4715 read=4901
69. 273.523 434.898 ↑ 1.0 703,961 1

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

  • Hash Cond: (time_logs.epic_id = epics.id)
  • Buffers: shared hit=4715 read=4901
70. 143.644 143.644 ↑ 1.0 703,961 1

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

  • Buffers: shared hit=4254 read=4901
71. 5.732 17.731 ↑ 1.0 26,435 1

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

  • Buckets: 32768 Batches: 1 Memory Usage: 1424kB
  • Buffers: shared hit=461
72. 7.670 11.999 ↑ 1.0 26,435 1

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

  • Hash Cond: (epics.project_id = active_plan.project_id)
  • Buffers: shared hit=461
73. 2.834 2.834 ↑ 1.0 26,435 1

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

  • Buffers: shared hit=355
74. 0.483 1.495 ↑ 1.0 2,851 1

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

  • Buckets: 4096 Batches: 1 Memory Usage: 144kB
  • Buffers: shared hit=106
75. 1.012 1.012 ↑ 1.0 2,851 1

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

  • Filter: active
  • Rows Removed by Filter: 3188
  • Buffers: shared hit=106
76. 1.065 2.002 ↑ 1.0 5,812 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 292kB
  • Buffers: shared hit=98
77. 0.937 0.937 ↑ 1.0 5,812 1

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

  • Buffers: shared hit=98
78. 1.238 15.916 ↑ 1.0 4,221 1

Hash (cost=932.12..932.12 rows=4,249 width=40) (actual time=15.916..15.916 rows=4,221 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 370kB
  • Buffers: shared hit=85
79. 0.858 14.678 ↑ 1.0 4,221 1

Subquery Scan on sa (cost=847.14..932.12 rows=4,249 width=40) (actual time=12.720..14.678 rows=4,221 loops=1)

  • Buffers: shared hit=85
80. 0.805 13.820 ↑ 1.0 4,221 1

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

  • Buffers: shared hit=85
81. 3.098 13.015 ↑ 1.0 4,249 1

Sort (cost=847.14..857.76 rows=4,249 width=65) (actual time=12.717..13.015 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
  • Buffers: shared hit=85
82. 3.568 9.917 ↑ 1.0 4,249 1

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

  • Buffers: shared hit=85
83. 2.195 6.349 ↑ 1.0 4,249 1

Sort (cost=484.85..495.47 rows=4,249 width=56) (actual time=5.986..6.349 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
  • Buffers: shared hit=85
84. 1.383 4.154 ↑ 1.0 4,249 1

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

  • Hash Cond: (staff_membership_activity_links.staff_membership_id = staff_memberships_1.id)
  • Buffers: shared hit=85
85. 0.392 0.392 ↑ 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.009..0.392 rows=4,256 loops=1)

  • Buffers: shared hit=37
86. 1.266 2.379 ↑ 1.0 4,002 1

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

  • Buckets: 4096 Batches: 1 Memory Usage: 276kB
  • Buffers: shared hit=48
87. 1.113 1.113 ↑ 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.009..1.113 rows=4,002 loops=1)

  • Buffers: shared hit=48
88. 0.061 0.154 ↑ 1.0 354 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
  • Buffers: shared hit=11
89. 0.093 0.093 ↑ 1.0 354 1

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

  • Buffers: shared hit=11
90. 13.567 310.756 ↑ 8.5 28,906 1

Subquery Scan on *SELECT* 2_1 (cost=424,372.25..513,596.17 rows=245,158 width=136) (actual time=97.041..310.756 rows=28,906 loops=1)

  • Buffers: shared hit=1052
91. 178.391 297.189 ↑ 8.5 28,906 1

Hash Anti Join (cost=424,372.25..510,531.69 rows=245,158 width=143) (actual time=97.038..297.189 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: 1153172
  • Buffers: shared hit=1052
92. 23.875 95.692 ↑ 9.5 29,394 1

Hash Join (cost=422,195.45..490,256.83 rows=280,181 width=64) (actual time=73.891..95.692 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: 10924
  • Buffers: shared hit=368
93. 1.358 15.997 ↑ 1.0 4,221 1

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

  • Buffers: shared hit=85
94. 3.847 14.639 ↑ 1.0 4,249 1

Sort (cost=836.52..847.14 rows=4,249 width=65) (actual time=14.112..14.639 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
  • Buffers: shared hit=85
95. 3.641 10.792 ↑ 1.0 4,249 1

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

  • Buffers: shared hit=85
96. 2.402 7.151 ↑ 1.0 4,249 1

Sort (cost=484.85..495.47 rows=4,249 width=44) (actual time=6.796..7.151 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
  • Buffers: shared hit=85
97. 1.958 4.749 ↑ 1.0 4,249 1

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

  • Hash Cond: (staff_membership_activity_links_1.staff_membership_id = staff_memberships_2.id)
  • Buffers: shared hit=85
98. 0.642 0.642 ↑ 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.015..0.642 rows=4,256 loops=1)

  • Buffers: shared hit=37
99. 1.135 2.149 ↑ 1.0 4,002 1

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

  • Buckets: 4096 Batches: 1 Memory Usage: 245kB
  • Buffers: shared hit=48
100. 1.014 1.014 ↑ 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.009..1.014 rows=4,002 loops=1)

  • Buffers: shared hit=48
101. 9.724 55.820 ↑ 17.5 31,132 1

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

  • Buckets: 1048576 Batches: 1 Memory Usage: 10776kB
  • Buffers: shared hit=283
102. 21.923 46.096 ↑ 17.5 31,132 1

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

  • Buffers: shared hit=283
103. 2.381 2.381 ↑ 1.0 21,792 1

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

  • Buffers: shared hit=283
104. 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
105. 12.039 23.106 ↑ 1.0 58,975 1

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

  • Buckets: 65536 Batches: 1 Memory Usage: 3047kB
  • Buffers: shared hit=684
106. 11.067 11.067 ↑ 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..11.067 rows=59,712 loops=1)

  • Buffers: shared hit=684
107. 0.003 0.123 ↑ 11.8 10 1

Hash (cost=17.20..17.20 rows=118 width=4) (actual time=0.123..0.123 rows=10 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=11
108. 0.120 0.120 ↑ 11.8 10 1

Seq Scan on accounts (cost=0.00..17.20 rows=118 width=4) (actual time=0.020..0.120 rows=10 loops=1)

  • Filter: ((suspended_at)::date >= CURRENT_DATE)
  • Rows Removed by Filter: 344
  • Buffers: shared hit=11
109. 101.405 414.983 ↑ 1.0 263,033 1

Hash (cost=23,315.28..23,315.28 rows=270,995 width=44) (actual time=414.983..414.983 rows=263,033 loops=1)

  • Buckets: 524288 Batches: 1 Memory Usage: 24593kB
  • Buffers: shared hit=9627
110. 33.584 313.578 ↑ 1.0 263,033 1

Append (cost=109.73..23,315.28 rows=270,995 width=44) (actual time=2.044..313.578 rows=263,033 loops=1)

  • Buffers: shared hit=9627
111. 0.118 23.339 ↓ 9.7 474 1

Subquery Scan on *SELECT* 1 (cost=109.73..1,614.47 rows=49 width=44) (actual time=2.043..23.339 rows=474 loops=1)

  • Buffers: shared hit=3549
112. 0.204 23.221 ↓ 9.7 474 1

Nested Loop (cost=109.73..1,613.98 rows=49 width=612) (actual time=2.042..23.221 rows=474 loops=1)

  • Buffers: shared hit=3549
113. 0.136 22.543 ↓ 9.7 474 1

Nested Loop (cost=109.59..1,606.06 rows=49 width=52) (actual time=2.034..22.543 rows=474 loops=1)

  • Buffers: shared hit=2601
114. 0.072 1.512 ↓ 5.0 5 1

Nested Loop (cost=109.17..277.90 rows=1 width=32) (actual time=1.309..1.512 rows=5 loops=1)

  • Join Filter: (clients.brand_id = rate_cards.rateable_id)
  • Rows Removed by Join Filter: 570
  • Buffers: shared hit=144
115. 0.090 0.635 ↑ 1.0 115 1

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

  • Buffers: shared hit=44
116. 0.045 0.545 ↑ 1.0 115 1

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

  • Sort Key: rate_cards.rateable_id, rate_cards.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 33kB
  • Buffers: shared hit=44
117. 0.500 0.500 ↑ 1.0 115 1

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

  • Filter: ((rateable_type)::text = 'Brand'::text)
  • Rows Removed by Filter: 4739
  • Buffers: shared hit=44
118. 0.051 0.805 ↑ 1.0 5 115

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

  • Buffers: shared hit=100
119. 0.003 0.754 ↑ 1.0 5 1

Nested Loop (cost=0.56..156.63 rows=5 width=8) (actual time=0.414..0.754 rows=5 loops=1)

  • Buffers: shared hit=100
120. 0.008 0.736 ↑ 1.0 5 1

Nested Loop (cost=0.28..155.13 rows=5 width=8) (actual time=0.406..0.736 rows=5 loops=1)

  • Buffers: shared hit=85
121. 0.713 0.713 ↑ 1.0 5 1

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

  • Filter: ((rates_type)::text = 'brand'::text)
  • Rows Removed by Filter: 5805
  • Buffers: shared hit=70
122. 0.015 0.015 ↑ 1.0 1 5

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

  • Index Cond: (id = pricing_models.project_id)
  • Buffers: shared hit=15
123. 0.015 0.015 ↑ 1.0 1 5

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

  • Index Cond: (id = projects_2.client_id)
  • Buffers: shared hit=15
124. 20.895 20.895 ↓ 1.9 95 5

Index Scan using index_rates_on_activity_id_and_rate_card_id on rates (cost=0.42..1,327.66 rows=49 width=28) (actual time=0.733..4.179 rows=95 loops=5)

  • Index Cond: (rate_card_id = rate_cards.id)
  • Buffers: shared hit=2457
125. 0.474 0.474 ↑ 1.0 1 474

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

  • Index Cond: (id = clients.brand_id)
  • Heap Fetches: 474
  • Buffers: shared hit=948
126. 16.108 81.412 ↓ 2.6 91,600 1

Subquery Scan on *SELECT* 2 (cost=583.00..5,479.99 rows=35,024 width=44) (actual time=11.894..81.412 rows=91,600 loops=1)

  • Buffers: shared hit=2036
127. 41.075 65.304 ↓ 2.6 91,600 1

Hash Join (cost=583.00..5,129.75 rows=35,024 width=612) (actual time=11.892..65.304 rows=91,600 loops=1)

  • Hash Cond: (rates_1.rate_card_id = rate_cards_1.id)
  • Buffers: shared hit=2036
128. 18.982 18.982 ↑ 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..18.982 rows=174,437 loops=1)

  • Buffers: shared hit=1798
129. 0.231 5.247 ↑ 1.1 657 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 47kB
  • Buffers: shared hit=238
130. 0.197 5.016 ↑ 1.1 657 1

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

  • Hash Cond: (clients_1.office_id = offices.id)
  • Buffers: shared hit=238
131. 0.182 3.472 ↑ 1.0 623 1

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

  • Hash Cond: (projects_3.client_id = clients_1.id)
  • Buffers: shared hit=190
132. 0.946 2.683 ↑ 1.0 623 1

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

  • Hash Cond: (projects_3.id = pricing_models_1.project_id)
  • Buffers: shared hit=168
133. 0.724 0.724 ↑ 1.0 5,812 1

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

  • Buffers: shared hit=98
134. 0.105 1.013 ↑ 1.0 623 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 30kB
  • Buffers: shared hit=70
135. 0.908 0.908 ↑ 1.0 623 1

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

  • Filter: ((rates_type)::text = 'office'::text)
  • Rows Removed by Filter: 5187
  • Buffers: shared hit=70
136. 0.288 0.607 ↑ 1.0 1,849 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 89kB
  • Buffers: shared hit=22
137. 0.319 0.319 ↑ 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.319 rows=1,849 loops=1)

  • Buffers: shared hit=22
138. 0.105 1.347 ↑ 1.1 450 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 35kB
  • Buffers: shared hit=48
139. 0.118 1.242 ↑ 1.1 450 1

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

  • Hash Cond: (rate_cards_1.rateable_id = offices.id)
  • Buffers: shared hit=48
140. 0.306 1.000 ↑ 1.0 489 1

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

  • Buffers: shared hit=44
141. 0.166 0.694 ↑ 1.0 489 1

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

  • Sort Key: rate_cards_1.rateable_id, rate_cards_1.start_date DESC NULLS LAST
  • Sort Method: quicksort Memory: 63kB
  • Buffers: shared hit=44
142. 0.528 0.528 ↑ 1.0 489 1

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

  • Filter: ((rateable_type)::text = 'Office'::text)
  • Rows Removed by Filter: 4365
  • Buffers: shared hit=44
143. 0.069 0.124 ↑ 1.0 441 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
  • Buffers: shared hit=4
144. 0.055 0.055 ↑ 1.0 441 1

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

  • Buffers: shared hit=4
145. 17.122 92.042 ↑ 2.2 94,593 1

Subquery Scan on *SELECT* 3 (cost=840.78..9,338.49 rows=204,158 width=44) (actual time=10.894..92.042 rows=94,593 loops=1)

  • Buffers: shared hit=2032
146. 44.444 74.920 ↑ 2.2 94,593 1

Hash Join (cost=840.78..7,296.91 rows=204,158 width=612) (actual time=10.893..74.920 rows=94,593 loops=1)

  • Hash Cond: (rates_2.rate_card_id = rate_cards_2.id)
  • Buffers: shared hit=2032
147. 19.673 19.673 ↑ 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.010..19.673 rows=174,437 loops=1)

  • Buffers: shared hit=1798
148. 1.045 10.803 ↑ 1.0 4,004 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 299kB
  • Buffers: shared hit=234
149. 1.154 9.758 ↑ 1.0 4,004 1

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

  • Hash Cond: (projects_4.client_id = clients_2.id)
  • Buffers: shared hit=234
150. 1.087 4.321 ↑ 1.0 3,620 1

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

  • Hash Cond: (pricing_models_2.project_id = projects_4.id)
  • Buffers: shared hit=168
151. 0.977 0.977 ↑ 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.977 rows=3,621 loops=1)

  • Filter: ((rates_type)::text = 'client'::text)
  • Rows Removed by Filter: 2189
  • Buffers: shared hit=70
152. 0.996 2.257 ↑ 1.0 5,812 1

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

  • Buckets: 8192 Batches: 1 Memory Usage: 292kB
  • Buffers: shared hit=98
153. 1.261 1.261 ↑ 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.261 rows=5,812 loops=1)

  • Buffers: shared hit=98
154. 0.524 4.283 ↑ 1.0 1,820 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 123kB
  • Buffers: shared hit=66
155. 0.489 3.759 ↑ 1.0 1,820 1

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

  • Hash Cond: (rate_cards_2.rateable_id = clients_2.id)
  • Buffers: shared hit=66
156. 1.318 2.749 ↑ 1.0 1,821 1

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

  • Buffers: shared hit=44
157. 0.764 1.431 ↑ 1.0 1,821 1

Sort (cost=203.29..207.84 rows=1,821 width=29) (actual time=1.281..1.431 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
  • Buffers: shared hit=44
158. 0.667 0.667 ↑ 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.667 rows=1,821 loops=1)

  • Filter: ((rateable_type)::text = 'Client'::text)
  • Rows Removed by Filter: 3033
  • Buffers: shared hit=44
159. 0.291 0.521 ↑ 1.0 1,849 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 82kB
  • Buffers: shared hit=22
160. 0.230 0.230 ↑ 1.0 1,849 1

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

  • Buffers: shared hit=22
161. 13.679 83.201 ↓ 2.4 76,366 1

Subquery Scan on *SELECT* 4 (cost=695.56..5,527.35 rows=31,764 width=44) (actual time=6.988..83.201 rows=76,366 loops=1)

  • Buffers: shared hit=2010
162. 41.887 69.522 ↓ 2.4 76,366 1

Hash Join (cost=695.56..5,209.71 rows=31,764 width=612) (actual time=6.987..69.522 rows=76,366 loops=1)

  • Hash Cond: (rates_3.rate_card_id = rate_cards_3.id)
  • Buffers: shared hit=2010
163. 20.682 20.682 ↑ 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.008..20.682 rows=174,437 loops=1)

  • Buffers: shared hit=1798
164. 0.408 6.953 ↓ 2.4 1,591 1

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

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 110kB
  • Buffers: shared hit=212
165. 0.996 6.545 ↓ 2.4 1,591 1

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

  • Hash Cond: (projects_5.id = pricing_models_3.project_id)
  • Buffers: shared hit=212
166. 0.601 0.601 ↑ 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.601 rows=5,812 loops=1)

  • Buffers: shared hit=98
167. 0.336 4.948 ↓ 2.4 1,591 1

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

  • Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 110kB
  • Buffers: shared hit=114
168. 0.480 4.612 ↓ 2.4 1,591 1

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

  • Hash Cond: (rate_cards_3.rateable_id = pricing_models_3.id)
  • Buffers: shared hit=114
169. 1.496 3.089 ↑ 1.0 2,429 1

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

  • Buffers: shared hit=44
170. 0.901 1.593 ↑ 1.0 2,429 1

Sort (cost=241.26..247.33 rows=2,429 width=29) (actual time=1.436..1.593 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
  • Buffers: shared hit=44
171. 0.692 0.692 ↑ 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.692 rows=2,429 loops=1)

  • Filter: ((rateable_type)::text = 'PricingModel'::text)
  • Rows Removed by Filter: 2425
  • Buffers: shared hit=44
172. 0.248 1.043 ↑ 1.0 1,561 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 77kB
  • Buffers: shared hit=70
173. 0.795 0.795 ↑ 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.008..0.795 rows=1,561 loops=1)

  • Filter: ((rates_type)::text = 'custom'::text)
  • Rows Removed by Filter: 4249
  • Buffers: shared hit=70
Planning time : 6.030 ms
Execution time : 92,192.025 ms