explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Od7D : Optimization for: Optimization for: Optimization for: plan #dPhA; plan #lML6; plan #i9vZ

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.021 0.655 ↓ 2.3 7 1

Sort (cost=125.07..125.08 rows=3 width=1,258) (actual time=0.654..0.655 rows=7 loops=1)

  • Sort Key: (CASE WHEN ((details.benefit_status)::text = 'IN_PROGRESS'::text) THEN 1 WHEN ((details.benefit_status)::text = 'ACTIVE'::text) THEN 2 WHEN ((details.benefit_status)::text = 'INACTIVE'::text) THEN 3 ELSE NULL::integer END), details.benefit_priority, details.benefit_start_date, details.order_date
  • Sort Method: quicksort Memory: 26kB
2. 0.008 0.634 ↓ 2.3 7 1

Subquery Scan on details (cost=124.97..125.05 rows=3 width=1,258) (actual time=0.621..0.634 rows=7 loops=1)

3. 0.032 0.626 ↓ 2.3 7 1

HashAggregate (cost=124.97..125.00 rows=3 width=1,254) (actual time=0.618..0.626 rows=7 loops=1)

  • Group Key: benefit_order.id, benefit_order.employee_id, benefit.name, benefit_type.name, benefit_type.beneficiary_type, benefit_type.priority, ('IN_PROGRESS'::character varying), benefit_order.order_date, (CASE WHEN (bbo.benefit_order_id IS NOT NULL) THEN bbo.beneficiary_first_name WHEN (employee_benefit.id IS NOT NULL) THEN employee_benefit.beneficiary_first_name ELSE NULL::character varying END), (CASE WHEN (bbo.benefit_order_id IS NOT NULL) THEN bbo.beneficiary_last_name WHEN (employee_benefit.id IS NOT NULL) THEN employee_benefit.beneficiary_last_name ELSE NULL::character varying END), (CASE WHEN (bbo.benefit_order_id IS NOT NULL) THEN bbo.benefit_start_date WHEN (rebo.benefit_order_id IS NOT NULL) THEN rebo.benefit_start_date ELSE NULL::timestamp without time zone END), (CASE WHEN (bbo.benefit_order_id IS NOT NULL) THEN bbo.benefit_end_date WHEN (rebo.benefit_order_id IS NOT NULL) THEN rebo.benefit_end_date ELSE NULL::timestamp without time zone END), (max(benefit_order_consent_given_by_employee.given_at))
4. 0.002 0.594 ↓ 2.3 7 1

Append (cost=43.42..124.87 rows=3 width=1,254) (actual time=0.263..0.594 rows=7 loops=1)

5. 0.015 0.291 ↓ 1.5 3 1

Nested Loop (cost=43.42..66.89 rows=2 width=1,254) (actual time=0.262..0.291 rows=3 loops=1)

  • Join Filter: (bbo.benefit_order_id = benefit_order.id)
  • Rows Removed by Join Filter: 18
6. 0.009 0.210 ↑ 1.3 3 1

Nested Loop Left Join (cost=31.77..43.16 rows=4 width=1,128) (actual time=0.195..0.210 rows=3 loops=1)

  • Join Filter: (rebo.benefit_order_id = benefit_order.id)
  • Rows Removed by Join Filter: 12
7. 0.014 0.165 ↑ 1.3 3 1

Hash Right Join (cost=30.68..31.37 rows=4 width=48) (actual time=0.157..0.165 rows=3 loops=1)

  • Hash Cond: (benefit_order_1.id = benefit_order.id)
8. 0.020 0.125 ↑ 3.3 9 1

HashAggregate (cost=29.46..29.76 rows=30 width=24) (actual time=0.120..0.125 rows=9 loops=1)

  • Group Key: benefit_order_1.id
9. 0.028 0.105 ↑ 1.6 19 1

HashAggregate (cost=28.71..29.01 rows=30 width=24) (actual time=0.096..0.105 rows=19 loops=1)

  • Group Key: benefit_order_1.id, benefit_order_consent_given_by_employee.given_at
10. 0.007 0.077 ↑ 1.2 25 1

Append (cost=1.26..28.56 rows=30 width=24) (actual time=0.025..0.077 rows=25 loops=1)

11. 0.023 0.046 ↓ 1.1 21 1

Hash Join (cost=1.26..16.33 rows=20 width=24) (actual time=0.024..0.046 rows=21 loops=1)

  • Hash Cond: (benefit_order_consent_given_by_employee.benefit_order_id = benefit_order_1.id)
12. 0.010 0.010 ↑ 16.7 24 1

Seq Scan on benefit_order_consent_given_by_employee (cost=0.00..14.00 rows=400 width=24) (actual time=0.005..0.010 rows=24 loops=1)

13. 0.005 0.013 ↑ 1.1 9 1

Hash (cost=1.14..1.14 rows=10 width=16) (actual time=0.013..0.013 rows=9 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
14. 0.008 0.008 ↑ 1.1 9 1

Seq Scan on benefit_order benefit_order_1 (cost=0.00..1.14 rows=10 width=16) (actual time=0.004..0.008 rows=9 loops=1)

  • Filter: ((status)::text <> 'WAITING_FOR_REQUIRED_ACTIONS'::text)
  • Rows Removed by Filter: 2
15. 0.007 0.024 ↑ 2.5 4 1

Hash Join (cost=1.26..11.78 rows=10 width=24) (actual time=0.020..0.024 rows=4 loops=1)

  • Hash Cond: (benefit_order_consent_given_by_family_member_or_friend.benefit_order_id = benefit_order_2.id)
16. 0.005 0.005 ↑ 10.0 4 1

Seq Scan on benefit_order_consent_given_by_family_member_or_friend (cost=0.00..10.40 rows=40 width=24) (actual time=0.004..0.005 rows=4 loops=1)

17. 0.004 0.012 ↑ 1.1 9 1

Hash (cost=1.14..1.14 rows=10 width=16) (actual time=0.012..0.012 rows=9 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
18. 0.008 0.008 ↑ 1.1 9 1

Seq Scan on benefit_order benefit_order_2 (cost=0.00..1.14 rows=10 width=16) (actual time=0.004..0.008 rows=9 loops=1)

  • Filter: ((status)::text <> 'WAITING_FOR_REQUIRED_ACTIONS'::text)
  • Rows Removed by Filter: 2
19. 0.004 0.026 ↑ 1.3 3 1

Hash (cost=1.17..1.17 rows=4 width=40) (actual time=0.026..0.026 rows=3 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
20. 0.022 0.022 ↑ 1.3 3 1

Seq Scan on benefit_order (cost=0.00..1.17 rows=4 width=40) (actual time=0.018..0.022 rows=3 loops=1)

  • Filter: ((status)::text = ANY ('{WAITING_FOR_REQUIRED_ACTIONS,READY_TO_PROCESS,SENT_TO_BENEFIT_PROVIDER_PLATFORM,RECEIVED_ON_BENEFIT_PROVIDER_PLATFORM}'::text[]))
  • Rows Removed by Filter: 8
21. 0.007 0.036 ↑ 1.0 4 3

Materialize (cost=1.09..11.56 rows=4 width=1,080) (actual time=0.007..0.012 rows=4 loops=3)

22. 0.015 0.029 ↑ 1.0 4 1

Hash Right Join (cost=1.09..11.54 rows=4 width=1,080) (actual time=0.019..0.029 rows=4 loops=1)

  • Hash Cond: (employee_benefit.id = rebo.employee_benefit_id)
23. 0.004 0.004 ↑ 7.5 4 1

Seq Scan on employee_benefit (cost=0.00..10.30 rows=30 width=1,048) (actual time=0.003..0.004 rows=4 loops=1)

24. 0.003 0.010 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=48) (actual time=0.010..0.010 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
25. 0.007 0.007 ↑ 1.0 4 1

Seq Scan on reactivate_employee_benefit_order rebo (cost=0.00..1.04 rows=4 width=48) (actual time=0.005..0.007 rows=4 loops=1)

26. 0.011 0.066 ↓ 1.8 7 3

Materialize (cost=11.66..23.50 rows=4 width=2,158) (actual time=0.016..0.022 rows=7 loops=3)

27. 0.014 0.055 ↓ 1.8 7 1

Hash Join (cost=11.66..23.48 rows=4 width=2,158) (actual time=0.047..0.055 rows=7 loops=1)

  • Hash Cond: (benefit_type.id = benefit.benefit_type_id)
28. 0.006 0.006 ↑ 32.5 4 1

Seq Scan on benefit_type (cost=0.00..11.30 rows=130 width=582) (actual time=0.005..0.006 rows=4 loops=1)

29. 0.006 0.035 ↓ 1.8 7 1

Hash (cost=11.61..11.61 rows=4 width=1,584) (actual time=0.035..0.035 rows=7 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
30. 0.011 0.029 ↓ 1.8 7 1

Hash Join (cost=1.09..11.61 rows=4 width=1,584) (actual time=0.018..0.029 rows=7 loops=1)

  • Hash Cond: (bbo.benefit_id = benefit.id)
31. 0.009 0.009 ↑ 5.7 7 1

Seq Scan on buy_benefit_order bbo (cost=0.00..10.40 rows=40 width=1,068) (actual time=0.005..0.009 rows=7 loops=1)

32. 0.003 0.009 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=524) (actual time=0.008..0.009 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
33. 0.006 0.006 ↑ 1.0 4 1

Seq Scan on benefit (cost=0.00..1.04 rows=4 width=524) (actual time=0.004..0.006 rows=4 loops=1)

34. 0.012 0.301 ↓ 4.0 4 1

Nested Loop Left Join (cost=41.56..57.93 rows=1 width=2,308) (actual time=0.230..0.301 rows=4 loops=1)

  • Join Filter: (benefit_order_5.id = result_with_row_number.benefit_order_id)
  • Rows Removed by Join Filter: 10
35. 0.008 0.173 ↓ 4.0 4 1

Nested Loop (cost=12.10..27.49 rows=1 width=2,316) (actual time=0.117..0.173 rows=4 loops=1)

36. 0.007 0.157 ↓ 4.0 4 1

Nested Loop (cost=11.96..21.24 rows=1 width=1,742) (actual time=0.111..0.157 rows=4 loops=1)

37. 0.008 0.142 ↓ 4.0 4 1

Nested Loop (cost=11.83..20.52 rows=1 width=1,226) (actual time=0.106..0.142 rows=4 loops=1)

38. 0.004 0.122 ↓ 4.0 4 1

Subquery Scan on result_with_row_number (cost=11.69..11.85 rows=1 width=40) (actual time=0.100..0.122 rows=4 loops=1)

  • Filter: (result_with_row_number.row_number = 1)
  • Rows Removed by Filter: 4
39. 0.025 0.118 ↓ 1.6 8 1

WindowAgg (cost=11.69..11.79 rows=5 width=48) (actual time=0.098..0.118 rows=8 loops=1)

40. 0.015 0.093 ↓ 1.6 8 1

Sort (cost=11.69..11.70 rows=5 width=40) (actual time=0.091..0.093 rows=8 loops=1)

  • Sort Key: buy_benefit_order.employee_benefit_id, benefit_order_3.order_date DESC
  • Sort Method: quicksort Memory: 25kB
41. 0.005 0.078 ↓ 1.6 8 1

Result (cost=0.14..11.63 rows=5 width=40) (actual time=0.020..0.078 rows=8 loops=1)

42. 0.002 0.073 ↓ 1.6 8 1

Append (cost=0.14..11.58 rows=5 width=40) (actual time=0.019..0.073 rows=8 loops=1)

43. 0.010 0.044 ↑ 1.0 4 1

Nested Loop (cost=0.14..9.30 rows=4 width=40) (actual time=0.019..0.044 rows=4 loops=1)

44. 0.010 0.010 ↓ 8.0 8 1

Seq Scan on benefit_order benefit_order_3 (cost=0.00..1.14 rows=1 width=24) (actual time=0.005..0.010 rows=8 loops=1)

  • Filter: ((status)::text = 'COMPLETED'::text)
  • Rows Removed by Filter: 3
45. 0.024 0.024 ↓ 0.0 0 8

Index Scan using idx__buy_benefit_order__benefit_order_id on buy_benefit_order (cost=0.14..8.16 rows=1 width=32) (actual time=0.003..0.003 rows=0 loops=8)

  • Index Cond: (benefit_order_id = benefit_order_3.id)
46. 0.009 0.027 ↓ 4.0 4 1

Hash Join (cost=1.15..2.20 rows=1 width=40) (actual time=0.023..0.027 rows=4 loops=1)

  • Hash Cond: (reactivate_employee_benefit_order.benefit_order_id = benefit_order_4.id)
47. 0.005 0.005 ↑ 1.0 4 1

Seq Scan on reactivate_employee_benefit_order (cost=0.00..1.04 rows=4 width=32) (actual time=0.004..0.005 rows=4 loops=1)

48. 0.004 0.013 ↓ 8.0 8 1

Hash (cost=1.14..1.14 rows=1 width=24) (actual time=0.013..0.013 rows=8 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
49. 0.009 0.009 ↓ 8.0 8 1

Seq Scan on benefit_order benefit_order_4 (cost=0.00..1.14 rows=1 width=24) (actual time=0.004..0.009 rows=8 loops=1)

  • Filter: ((status)::text = 'COMPLETED'::text)
  • Rows Removed by Filter: 3
50. 0.012 0.012 ↑ 1.0 1 4

Index Scan using employee_benefit_pkey on employee_benefit eb (cost=0.14..8.15 rows=1 width=1,202) (actual time=0.003..0.003 rows=1 loops=4)

  • Index Cond: (id = result_with_row_number.employee_benefit_id)
51. 0.008 0.008 ↑ 1.0 1 4

Index Scan using benefit_pkey on benefit benefit_1 (cost=0.13..0.55 rows=1 width=524) (actual time=0.002..0.002 rows=1 loops=4)

  • Index Cond: (id = eb.benefit_id)
52. 0.008 0.008 ↑ 1.0 1 4

Index Scan using benefit_type_pkey on benefit_type benefit_type_1 (cost=0.14..6.16 rows=1 width=582) (actual time=0.002..0.002 rows=1 loops=4)

  • Index Cond: (id = benefit_1.benefit_type_id)
53. 0.020 0.116 ↑ 7.5 4 4

HashAggregate (cost=29.46..29.76 rows=30 width=24) (actual time=0.028..0.029 rows=4 loops=4)

  • Group Key: benefit_order_5.id
54. 0.025 0.096 ↑ 1.6 19 1

HashAggregate (cost=28.71..29.01 rows=30 width=24) (actual time=0.088..0.096 rows=19 loops=1)

  • Group Key: benefit_order_5.id, benefit_order_consent_given_by_employee_1.given_at
55. 0.007 0.071 ↑ 1.2 25 1

Append (cost=1.26..28.56 rows=30 width=24) (actual time=0.022..0.071 rows=25 loops=1)

56. 0.021 0.042 ↓ 1.1 21 1

Hash Join (cost=1.26..16.33 rows=20 width=24) (actual time=0.021..0.042 rows=21 loops=1)

  • Hash Cond: (benefit_order_consent_given_by_employee_1.benefit_order_id = benefit_order_5.id)
57. 0.009 0.009 ↑ 16.7 24 1

Seq Scan on benefit_order_consent_given_by_employee benefit_order_consent_given_by_employee_1 (cost=0.00..14.00 rows=400 width=24) (actual time=0.004..0.009 rows=24 loops=1)

58. 0.005 0.012 ↑ 1.1 9 1

Hash (cost=1.14..1.14 rows=10 width=16) (actual time=0.011..0.012 rows=9 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
59. 0.007 0.007 ↑ 1.1 9 1

Seq Scan on benefit_order benefit_order_5 (cost=0.00..1.14 rows=10 width=16) (actual time=0.004..0.007 rows=9 loops=1)

  • Filter: ((status)::text <> 'WAITING_FOR_REQUIRED_ACTIONS'::text)
  • Rows Removed by Filter: 2
60. 0.007 0.022 ↑ 2.5 4 1

Hash Join (cost=1.26..11.78 rows=10 width=24) (actual time=0.019..0.022 rows=4 loops=1)

  • Hash Cond: (benefit_order_consent_given_by_family_member_or_friend_1.benefit_order_id = benefit_order_6.id)
61. 0.004 0.004 ↑ 10.0 4 1

Seq Scan on benefit_order_consent_given_by_family_member_or_friend benefit_order_consent_given_by_family_member_or_friend_1 (cost=0.00..10.40 rows=40 width=24) (actual time=0.003..0.004 rows=4 loops=1)

62. 0.004 0.011 ↑ 1.1 9 1

Hash (cost=1.14..1.14 rows=10 width=16) (actual time=0.011..0.011 rows=9 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
63. 0.007 0.007 ↑ 1.1 9 1

Seq Scan on benefit_order benefit_order_6 (cost=0.00..1.14 rows=10 width=16) (actual time=0.003..0.007 rows=9 loops=1)

  • Filter: ((status)::text <> 'WAITING_FOR_REQUIRED_ACTIONS'::text)
  • Rows Removed by Filter: 2
Planning time : 3.752 ms
Execution time : 1.063 ms