explain.depesz.com

PostgreSQL's explain analyze made readable

Result: IE0O

Settings
# exclusive inclusive rows x rows loops node
1. 2.642 15,046.433 ↑ 1.0 2 1

Nested Loop Anti Join (cost=18.61..2,334,674.98 rows=2 width=4,741) (actual time=7,502.888..15,046.433 rows=2 loops=1)

2.          

CTE definitions

3. 0.028 0.028 ↑ 1.0 1 1

Seq Scan on locations (cost=0.00..1.43 rows=1 width=67) (actual time=0.026..0.028 rows=1 loops=1)

  • Filter: (id = 1)
  • Rows Removed by Filter: 32
4.          

Initplan (for Nested Loop Anti Join)

5. 0.010 0.043 ↑ 1.0 1 1

HashAggregate (cost=0.02..0.03 rows=1 width=8) (actual time=0.043..0.043 rows=1 loops=1)

  • Group Key: definitions_1.location_id
6. 0.033 0.033 ↑ 1.0 1 1

CTE Scan on definitions definitions_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.031..0.033 rows=1 loops=1)

7. 0.005 0.556 ↑ 1.0 2 1

Nested Loop Left Join (cost=16.72..107.42 rows=2 width=254) (actual time=0.338..0.556 rows=2 loops=1)

  • Join Filter: (definitions.location_id = loans.location_id)
8. 0.006 0.539 ↑ 1.0 2 1

Nested Loop Left Join (cost=16.70..107.34 rows=2 width=222) (actual time=0.328..0.539 rows=2 loops=1)

9. 0.004 0.487 ↑ 1.0 2 1

Nested Loop Left Join (cost=16.27..67.21 rows=2 width=211) (actual time=0.298..0.487 rows=2 loops=1)

10. 0.024 0.451 ↓ 2.0 2 1

Nested Loop Left Join (cost=15.83..50.27 rows=1 width=198) (actual time=0.282..0.451 rows=2 loops=1)

11. 0.006 0.409 ↓ 2.0 2 1

Nested Loop Left Join (cost=15.56..49.97 rows=1 width=190) (actual time=0.249..0.409 rows=2 loops=1)

12. 0.055 0.385 ↓ 2.0 2 1

Nested Loop Left Join (cost=15.28..49.67 rows=1 width=163) (actual time=0.236..0.385 rows=2 loops=1)

13. 0.052 0.312 ↓ 2.0 2 1

Nested Loop Left Join (cost=8.34..36.72 rows=1 width=159) (actual time=0.198..0.312 rows=2 loops=1)

14. 0.007 0.256 ↓ 2.0 2 1

Nested Loop Left Join (cost=1.43..23.78 rows=1 width=150) (actual time=0.168..0.256 rows=2 loops=1)

  • Join Filter: (cl.location_id <> loans.location_id)
  • Rows Removed by Join Filter: 2
15. 0.007 0.181 ↓ 2.0 2 1

Nested Loop Left Join (cost=0.99..23.14 rows=1 width=155) (actual time=0.134..0.181 rows=2 loops=1)

16. 0.152 0.152 ↓ 2.0 2 1

Index Scan using loans_pkey on loans (cost=0.56..16.69 rows=1 width=120) (actual time=0.117..0.152 rows=2 loops=1)

  • Index Cond: (id = ANY ('{9813479,9813474,9813471}'::bigint[]))
  • Filter: ((NOT is_first_loan) AND (decision = ANY ('{1,2}'::integer[])) AND (status <> 15) AND (location_id = $1578))
  • Rows Removed by Filter: 1
17. 0.022 0.022 ↑ 1.0 1 2

Index Scan using customers_pkey on customers (cost=0.43..6.45 rows=1 width=35) (actual time=0.011..0.011 rows=1 loops=2)

  • Index Cond: (loans.customer_id = id)
18. 0.068 0.068 ↓ 2.0 2 2

Index Scan using customers_personal_number_index on customers cl (cost=0.43..0.63 rows=1 width=29) (actual time=0.026..0.034 rows=2 loops=2)

  • Index Cond: ((personal_number)::text = (customers.personal_number)::text)
  • Filter: (location_id = ANY ('{1,11}'::bigint[]))
  • Rows Removed by Filter: 0
19. 0.000 0.004 ↓ 0.0 0 2

Index Scan using loan_proposals_pkey on loan_proposals lp (cost=6.92..12.93 rows=1 width=17) (actual time=0.002..0.002 rows=0 loops=2)

  • Index Cond: (id = (SubPlan 641))
20.          

SubPlan (for Index Scan)

21. 0.004 0.042 ↓ 0.0 0 2

Limit (cost=6.48..6.49 rows=1 width=16) (actual time=0.021..0.021 rows=0 loops=2)

22. 0.020 0.038 ↓ 0.0 0 2

Sort (cost=6.48..6.49 rows=1 width=16) (actual time=0.019..0.019 rows=0 loops=2)

  • Sort Key: loan_proposals.created_at
  • Sort Method: quicksort Memory: 25kB
23. 0.018 0.018 ↓ 0.0 0 2

Index Scan using loan_proposals_loan_id_index on loan_proposals (cost=0.43..6.47 rows=1 width=16) (actual time=0.009..0.009 rows=0 loops=2)

  • Index Cond: (loan_id = loans.id)
  • Filter: (status = 3)
24. 0.000 0.018 ↑ 1.0 1 2

Index Scan using loan_loan_reason_pkey on loan_loan_reason llr (cost=6.93..12.95 rows=1 width=12) (actual time=0.009..0.009 rows=1 loops=2)

  • Index Cond: (id = (SubPlan 642))
25.          

SubPlan (for Index Scan)

26. 0.002 0.044 ↑ 1.0 1 2

Limit (cost=6.50..6.50 rows=1 width=16) (actual time=0.022..0.022 rows=1 loops=2)

27. 0.016 0.042 ↑ 2.0 1 2

Sort (cost=6.50..6.50 rows=2 width=16) (actual time=0.021..0.021 rows=1 loops=2)

  • Sort Key: loan_loan_reason.updated_at DESC
  • Sort Method: quicksort Memory: 25kB
28. 0.026 0.026 ↑ 2.0 1 2

Index Scan using loan_loan_reason_loan_id_index on loan_loan_reason (cost=0.43..6.49 rows=2 width=16) (actual time=0.012..0.013 rows=1 loops=2)

  • Index Cond: (loan_id = loans.id)
  • Filter: (deleted_at IS NULL)
29. 0.018 0.018 ↑ 1.0 1 2

Index Scan using loan_reasons_pkey on loan_reasons lr (cost=0.28..0.30 rows=1 width=39) (actual time=0.009..0.009 rows=1 loops=2)

  • Index Cond: (id = llr.loan_reason_id)
30. 0.018 0.018 ↑ 1.0 1 2

Index Scan using loan_reason_groups_pkey on loan_reason_groups lrg (cost=0.28..0.30 rows=1 width=24) (actual time=0.009..0.009 rows=1 loops=2)

  • Index Cond: (id = lr.loan_reason_group_id)
31. 0.032 0.032 ↑ 2.0 1 2

Index Scan using customer_contact_information_customer_id_index on customer_contact_information (cost=0.43..16.91 rows=2 width=21) (actual time=0.012..0.016 rows=1 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: (type = 0)
  • Rows Removed by Filter: 1
32. 0.026 0.046 ↑ 1.0 1 2

Index Scan using device_ident_customer_informations_customer_id_index on device_ident_customer_informations dici (cost=0.43..20.05 rows=1 width=27) (actual time=0.022..0.023 rows=1 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: (SubPlan 643)
33.          

SubPlan (for Index Scan)

34. 0.008 0.020 ↑ 1.0 1 2

Aggregate (cost=6.68..6.69 rows=1 width=8) (actual time=0.010..0.010 rows=1 loops=2)

35. 0.012 0.012 ↑ 1.0 1 2

Index Scan using device_ident_customer_informations_customer_id_index on device_ident_customer_informations d11 (cost=0.43..6.68 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((created_at <= loans.decision_date) AND (location_id = loans.location_id))
36. 0.008 0.012 ↑ 1.0 1 2

Materialize (cost=0.03..0.05 rows=1 width=40) (actual time=0.005..0.006 rows=1 loops=2)

37. 0.003 0.004 ↑ 1.0 1 1

HashAggregate (cost=0.03..0.04 rows=1 width=40) (actual time=0.004..0.004 rows=1 loops=1)

  • Group Key: definitions.phone_prefix, definitions.location_id
38. 0.001 0.001 ↑ 1.0 1 1

CTE Scan on definitions (cost=0.00..0.02 rows=1 width=40) (actual time=0.001..0.001 rows=1 loops=1)

  • Filter: (location_id = $1578)
39. 0.018 0.018 ↓ 0.0 0 2

Index Scan using prolong_history_to_loan_id_index on prolong_history (cost=0.42..6.44 rows=1 width=8) (actual time=0.009..0.009 rows=0 loops=2)

  • Index Cond: (to_loan_id = loans.id)
  • Filter: (deleted_at IS NULL)
40.          

SubPlan (for Nested Loop Anti Join)

41. 0.006 0.128 ↑ 1.0 1 2

Aggregate (cost=19.67..19.68 rows=1 width=8) (actual time=0.064..0.064 rows=1 loops=2)

42. 0.122 0.122 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans rl (cost=0.43..19.67 rows=1 width=0) (actual time=0.031..0.061 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((created_at < loans.created_at) AND (status = 5))
  • Rows Removed by Filter: 12
43. 0.018 0.018 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_1 (cost=0.42..8.62 rows=5 width=0) (actual time=0.009..0.009 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
44. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_2 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
45. 0.000 0.000 ↓ 0.0 0

Limit (cost=41.59..41.60 rows=1 width=16) (never executed)

46. 0.000 0.000 ↓ 0.0 0

Sort (cost=41.59..41.61 rows=5 width=16) (never executed)

  • Sort Key: l1.created_at DESC
47. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=16) (never executed)

48. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_3.to_loan_id
49. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_3 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
50. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_3.to_loan_id)
51. 0.016 0.016 ↑ 1.0 1 2

Seq Scan on locations loc (cost=0.00..1.41 rows=1 width=14) (actual time=0.006..0.008 rows=1 loops=2)

  • Filter: (id = loans.location_id)
  • Rows Removed by Filter: 32
52. 0.010 0.010 ↑ 1.0 1 2

Seq Scan on locations loc_1 (cost=0.00..1.41 rows=1 width=14) (actual time=0.004..0.005 rows=1 loops=2)

  • Filter: (id = loans.location_id)
  • Rows Removed by Filter: 32
53. 0.008 0.008 ↑ 1.0 1 2

Seq Scan on locations loc_2 (cost=0.00..1.41 rows=1 width=14) (actual time=0.003..0.004 rows=1 loops=2)

  • Filter: (id = loans.location_id)
  • Rows Removed by Filter: 32
54. 0.008 0.008 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_4 (cost=0.42..8.62 rows=5 width=0) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
55. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_5 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
56. 0.000 0.000 ↓ 0.0 0

Limit (cost=41.59..41.60 rows=1 width=16) (never executed)

57. 0.000 0.000 ↓ 0.0 0

Sort (cost=41.59..41.61 rows=5 width=16) (never executed)

  • Sort Key: l1_1.created_at DESC
58. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=16) (never executed)

59. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_6.to_loan_id
60. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_6 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
61. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_1 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_6.to_loan_id)
62. 0.004 0.016 ↑ 1.0 1 2

Aggregate (cost=41.58..41.59 rows=1 width=8) (actual time=0.007..0.008 rows=1 loops=2)

63. 0.002 0.012 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=8) (actual time=0.006..0.006 rows=0 loops=2)

64. 0.004 0.010 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Group Key: prolong_history_7.to_loan_id
65. 0.006 0.006 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_7 (cost=0.42..8.62 rows=5 width=8) (actual time=0.003..0.003 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
66. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_2 (cost=0.56..6.58 rows=1 width=16) (never executed)

  • Index Cond: (id = prolong_history_7.to_loan_id)
67. 0.002 0.018 ↑ 1.0 1 2

Aggregate (cost=41.58..41.59 rows=1 width=8) (actual time=0.009..0.009 rows=1 loops=2)

68. 0.002 0.016 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.008..0.008 rows=0 loops=2)

69. 0.002 0.014 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.007..0.007 rows=0 loops=2)

  • Group Key: prolong_history_8.to_loan_id
70. 0.012 0.012 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_8 (cost=0.42..8.62 rows=5 width=8) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
71. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_8.to_loan_id)
72. 0.004 0.022 ↑ 1.0 1 2

Aggregate (cost=14.20..14.21 rows=1 width=8) (actual time=0.010..0.011 rows=1 loops=2)

73. 0.018 0.018 ↓ 0.0 0 2

Index Scan using extensions_loan_id_index on extensions (cost=0.43..14.18 rows=6 width=8) (actual time=0.009..0.009 rows=0 loops=2)

  • Index Cond: (loan_id = loans.id)
  • Filter: ((deleted_at IS NULL) AND (status = 1))
74. 0.002 0.010 ↑ 1.0 1 2

Aggregate (cost=8.63..8.64 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=2)

75. 0.008 0.008 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_9 (cost=0.42..8.62 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
76. 0.010 0.018 ↑ 1.0 1 2

Aggregate (cost=14.20..14.21 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=2)

77. 0.008 0.008 ↓ 0.0 0 2

Index Scan using extensions_loan_id_index on extensions extensions_1 (cost=0.43..14.18 rows=6 width=6) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (loan_id = loans.id)
  • Filter: ((deleted_at IS NULL) AND (status = 1))
78. 0.002 0.014 ↑ 1.0 1 2

Aggregate (cost=40,689.60..40,689.61 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=2)

79.          

Initplan (for Aggregate)

80. 0.000 0.000 ↓ 0.0 0

Seq Scan on fee_types (cost=0.00..11.87 rows=1 width=8) (never executed)

  • Filter: ((location_id = loans.location_id) AND ((internal_name)::text = 'consolidation_fee'::text))
81. 0.002 0.012 ↓ 0.0 0 2

Nested Loop (cost=9.20..40,677.28 rows=179 width=4) (actual time=0.006..0.006 rows=0 loops=2)

82. 0.002 0.010 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Group Key: prolong_history_10.to_loan_id
83. 0.008 0.008 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_10 (cost=0.42..8.62 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
84. 0.000 0.000 ↓ 0.0 0

Index Scan using fees_loan_id_index on fees (cost=0.57..8,133.36 rows=36 width=12) (never executed)

  • Index Cond: (loan_id = prolong_history_10.to_loan_id)
  • Filter: (fee_type_id = $22)
85. 0.002 0.010 ↑ 1.0 1 2

Aggregate (cost=14.20..14.21 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=2)

86. 0.008 0.008 ↓ 0.0 0 2

Index Scan using extensions_loan_id_index on extensions extensions_2 (cost=0.43..14.18 rows=6 width=4) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (loan_id = loans.id)
  • Filter: ((deleted_at IS NULL) AND (status = 1))
87. 0.004 0.014 ↑ 1.0 1 2

Aggregate (cost=41.58..41.59 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=2)

88. 0.000 0.010 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.005..0.005 rows=0 loops=2)

89. 0.004 0.010 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Group Key: prolong_history_11.to_loan_id
90. 0.006 0.006 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_11 (cost=0.42..8.62 rows=5 width=8) (actual time=0.003..0.003 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
91. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_1 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_11.to_loan_id)
92. 0.002 0.018 ↑ 1.0 1 2

Aggregate (cost=41.58..41.59 rows=1 width=32) (actual time=0.009..0.009 rows=1 loops=2)

93. 0.002 0.016 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.008..0.008 rows=0 loops=2)

94. 0.002 0.014 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.007..0.007 rows=0 loops=2)

  • Group Key: prolong_history_12.to_loan_id
95. 0.012 0.012 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_12 (cost=0.42..8.62 rows=5 width=8) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
96. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_2 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_12.to_loan_id)
97. 0.002 0.012 ↑ 1.0 1 2

Aggregate (cost=41.58..41.59 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=2)

98. 0.002 0.010 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=5) (actual time=0.005..0.005 rows=0 loops=2)

99. 0.002 0.008 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Group Key: prolong_history_13.to_loan_id
100. 0.006 0.006 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_13 (cost=0.42..8.62 rows=5 width=8) (actual time=0.003..0.003 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
101. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_3 (cost=0.56..6.58 rows=1 width=13) (never executed)

  • Index Cond: (id = prolong_history_13.to_loan_id)
102. 0.002 3.486 ↓ 0.0 0 2

Limit (cost=163.79..163.79 rows=1 width=40) (actual time=1.743..1.743 rows=0 loops=2)

103. 0.698 3.484 ↓ 0.0 0 2

Sort (cost=163.79..163.79 rows=1 width=40) (actual time=1.742..1.742 rows=0 loops=2)

  • Sort Key: revisions_customers.created_at
  • Sort Method: quicksort Memory: 25kB
104. 2.786 2.786 ↓ 0.0 0 2

Foreign Scan on revisions_customers (cost=100.57..163.78 rows=1 width=40) (actual time=1.393..1.393 rows=0 loops=2)

  • Filter: (created_at > COALESCE(loans.sas_execution, loans.created_at))
  • Rows Removed by Filter: 0
105. 0.006 0.034 ↑ 1.0 1 2

Aggregate (cost=14.20..14.21 rows=1 width=8) (actual time=0.017..0.017 rows=1 loops=2)

106. 0.028 0.028 ↓ 0.0 0 2

Index Scan using extensions_loan_id_index on extensions extensions_3 (cost=0.43..14.18 rows=6 width=8) (actual time=0.014..0.014 rows=0 loops=2)

  • Index Cond: (loan_id = loans.id)
  • Filter: ((deleted_at IS NULL) AND (status = 1))
107. 0.004 0.026 ↑ 1.0 1 2

Aggregate (cost=8.63..8.64 rows=1 width=8) (actual time=0.012..0.013 rows=1 loops=2)

108. 0.022 0.022 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_14 (cost=0.42..8.62 rows=5 width=0) (actual time=0.011..0.011 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
109. 0.002 0.034 ↓ 0.0 0 2

Limit (cost=41.59..41.60 rows=1 width=12) (actual time=0.017..0.017 rows=0 loops=2)

110. 0.016 0.032 ↓ 0.0 0 2

Sort (cost=41.59..41.61 rows=5 width=12) (actual time=0.016..0.016 rows=0 loops=2)

  • Sort Key: l1_3.created_at DESC
  • Sort Method: quicksort Memory: 25kB
111. 0.002 0.016 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=12) (actual time=0.008..0.008 rows=0 loops=2)

112. 0.004 0.014 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.007..0.007 rows=0 loops=2)

  • Group Key: prolong_history_15.to_loan_id
113. 0.010 0.010 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_15 (cost=0.42..8.62 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
114. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_3 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_15.to_loan_id)
115. 0.002 0.028 ↓ 0.0 0 2

Limit (cost=41.59..41.60 rows=1 width=12) (actual time=0.014..0.014 rows=0 loops=2)

116. 0.012 0.026 ↓ 0.0 0 2

Sort (cost=41.59..41.61 rows=5 width=12) (actual time=0.013..0.013 rows=0 loops=2)

  • Sort Key: l1_4.created_at DESC
  • Sort Method: quicksort Memory: 25kB
117. 0.002 0.014 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=12) (actual time=0.007..0.007 rows=0 loops=2)

118. 0.004 0.012 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.006..0.006 rows=0 loops=2)

  • Group Key: prolong_history_16.to_loan_id
119. 0.008 0.008 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_16 (cost=0.42..8.62 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
120. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_4 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_16.to_loan_id)
121. 0.000 0.000 ↓ 0.0 0

Limit (cost=41.59..41.60 rows=1 width=12) (never executed)

122. 0.000 0.000 ↓ 0.0 0

Sort (cost=41.59..41.61 rows=5 width=12) (never executed)

  • Sort Key: l1_5.created_at DESC
123. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=12) (never executed)

124. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_17.to_loan_id
125. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_17 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
126. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_5 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_17.to_loan_id)
127. 0.000 0.000 ↓ 0.0 0

Limit (cost=41.59..41.60 rows=1 width=12) (never executed)

128. 0.000 0.000 ↓ 0.0 0

Sort (cost=41.59..41.61 rows=5 width=12) (never executed)

  • Sort Key: l1_6.created_at DESC
129. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=12) (never executed)

130. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_18.to_loan_id
131. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_18 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
132. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_6 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_18.to_loan_id)
133. 0.002 0.022 ↓ 0.0 0 2

Limit (cost=41.59..41.60 rows=1 width=12) (actual time=0.011..0.011 rows=0 loops=2)

134. 0.006 0.020 ↓ 0.0 0 2

Sort (cost=41.59..41.61 rows=5 width=12) (actual time=0.010..0.010 rows=0 loops=2)

  • Sort Key: l1_7.created_at DESC
  • Sort Method: quicksort Memory: 25kB
135. 0.002 0.014 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=12) (actual time=0.007..0.007 rows=0 loops=2)

136. 0.004 0.012 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.005..0.006 rows=0 loops=2)

  • Group Key: prolong_history_19.to_loan_id
137. 0.008 0.008 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_19 (cost=0.42..8.62 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
138. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_7 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_19.to_loan_id)
139. 0.004 0.014 ↑ 1.0 1 2

Aggregate (cost=41.58..41.59 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=2)

140. 0.002 0.010 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.005..0.005 rows=0 loops=2)

141. 0.002 0.008 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Group Key: prolong_history_20.to_loan_id
142. 0.006 0.006 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_20 (cost=0.42..8.62 rows=5 width=8) (actual time=0.003..0.003 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
143. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_4 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_20.to_loan_id)
144. 0.000 0.024 ↓ 0.0 0 2

Limit (cost=41.59..41.60 rows=1 width=12) (actual time=0.012..0.012 rows=0 loops=2)

145. 0.012 0.024 ↓ 0.0 0 2

Sort (cost=41.59..41.61 rows=5 width=12) (actual time=0.012..0.012 rows=0 loops=2)

  • Sort Key: l1_8.created_at DESC
  • Sort Method: quicksort Memory: 25kB
146. 0.002 0.012 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=12) (actual time=0.006..0.006 rows=0 loops=2)

147. 0.002 0.010 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Group Key: prolong_history_21.to_loan_id
148. 0.008 0.008 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_21 (cost=0.42..8.62 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
149. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_8 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_21.to_loan_id)
150. 0.001 0.017 ↓ 0.0 0 1

Limit (cost=41.59..41.60 rows=1 width=12) (actual time=0.017..0.017 rows=0 loops=1)

151. 0.009 0.016 ↓ 0.0 0 1

Sort (cost=41.59..41.61 rows=5 width=12) (actual time=0.016..0.016 rows=0 loops=1)

  • Sort Key: l1_9.created_at DESC
  • Sort Method: quicksort Memory: 25kB
152. 0.001 0.007 ↓ 0.0 0 1

Nested Loop (cost=9.19..41.57 rows=5 width=12) (actual time=0.007..0.007 rows=0 loops=1)

153. 0.001 0.006 ↓ 0.0 0 1

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.006..0.006 rows=0 loops=1)

  • Group Key: prolong_history_22.to_loan_id
154. 0.005 0.005 ↓ 0.0 0 1

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_22 (cost=0.42..8.62 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=1)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
155. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_9 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_22.to_loan_id)
156. 0.000 0.000 ↓ 0.0 0

Limit (cost=41.59..41.60 rows=1 width=12) (never executed)

157. 0.000 0.000 ↓ 0.0 0

Sort (cost=41.59..41.61 rows=5 width=12) (never executed)

  • Sort Key: l1_10.created_at DESC
158. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=12) (never executed)

159. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_23.to_loan_id
160. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_23 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = loans.id)
  • Filter: (deleted_at IS NULL)
161. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_10 (cost=0.56..6.58 rows=1 width=20) (never executed)

  • Index Cond: (id = prolong_history_23.to_loan_id)
162. 0.004 0.068 ↑ 1.0 1 2

Limit (cost=21.96..21.96 rows=1 width=16) (actual time=0.033..0.034 rows=1 loops=2)

163. 0.022 0.064 ↑ 144.0 1 2

Sort (cost=21.96..22.32 rows=144 width=16) (actual time=0.032..0.032 rows=1 loops=2)

  • Sort Key: sas_history.id DESC
  • Sort Method: top-N heapsort Memory: 25kB
164. 0.042 0.042 ↑ 24.0 6 2

Index Scan using sas_history_loan_id_index on sas_history (cost=0.56..21.24 rows=144 width=16) (actual time=0.016..0.021 rows=6 loops=2)

  • Index Cond: (loan_id = loans.id)
165. 0.002 0.038 ↑ 1.0 1 2

Limit (cost=21.96..21.96 rows=1 width=16) (actual time=0.019..0.019 rows=1 loops=2)

166. 0.018 0.036 ↑ 144.0 1 2

Sort (cost=21.96..22.32 rows=144 width=16) (actual time=0.018..0.018 rows=1 loops=2)

  • Sort Key: sas_history_1.id DESC
  • Sort Method: top-N heapsort Memory: 25kB
167. 0.018 0.018 ↑ 24.0 6 2

Index Scan using sas_history_loan_id_index on sas_history sas_history_1 (cost=0.56..21.24 rows=144 width=16) (actual time=0.006..0.009 rows=6 loops=2)

  • Index Cond: (loan_id = loans.id)
168. 0.008 0.072 ↑ 1.0 1 2

Aggregate (cost=19.67..19.68 rows=1 width=8) (actual time=0.036..0.036 rows=1 loops=2)

169. 0.064 0.064 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans rl_1 (cost=0.43..19.67 rows=1 width=8) (actual time=0.021..0.032 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((created_at < loans.created_at) AND (decision = 2))
  • Rows Removed by Filter: 12
170. 0.004 0.028 ↑ 1.0 1 2

Aggregate (cost=19.67..19.68 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=2)

171. 0.024 0.024 ↓ 2.0 2 2

Index Scan using loans_customer_id_index on loans rl_2 (cost=0.43..19.67 rows=1 width=8) (actual time=0.008..0.012 rows=2 loops=2)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((created_at < loans.created_at) AND (decision = 2))
  • Rows Removed by Filter: 0
172. 0.014 0.076 ↑ 1.0 1 2

Aggregate (cost=40.46..40.47 rows=1 width=8) (actual time=0.038..0.038 rows=1 loops=2)

173. 0.062 0.062 ↓ 4.0 12 2

Index Scan using loans_customer_id_index on loans rl_3 (cost=0.43..40.46 rows=3 width=8) (actual time=0.019..0.031 rows=12 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((created_at < loans.created_at) AND (decision = 2))
  • Rows Removed by Filter: 12
174. 0.004 0.068 ↑ 1.0 1 2

Aggregate (cost=19.67..19.68 rows=1 width=8) (actual time=0.034..0.034 rows=1 loops=2)

175. 0.064 0.064 ↑ 1.0 1 2

Index Scan using loans_customer_id_index on loans rl_4 (cost=0.43..19.67 rows=1 width=8) (actual time=0.022..0.032 rows=1 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((created_at < loans.created_at) AND (status = 15))
  • Rows Removed by Filter: 20
176. 0.004 0.018 ↑ 1.0 1 2

Aggregate (cost=19.67..19.68 rows=1 width=8) (actual time=0.009..0.009 rows=1 loops=2)

177. 0.014 0.014 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_5 (cost=0.43..19.67 rows=1 width=8) (actual time=0.006..0.007 rows=0 loops=2)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((created_at < loans.created_at) AND (status = 15))
  • Rows Removed by Filter: 2
178. 0.008 0.066 ↑ 1.0 1 2

Aggregate (cost=40.46..40.47 rows=1 width=8) (actual time=0.033..0.033 rows=1 loops=2)

179. 0.058 0.058 ↓ 2.0 2 2

Index Scan using loans_customer_id_index on loans rl_6 (cost=0.43..40.46 rows=1 width=8) (actual time=0.024..0.029 rows=2 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((created_at < loans.created_at) AND (status = 15))
  • Rows Removed by Filter: 22
180. 0.004 0.084 ↑ 1.0 1 2

Limit (cost=19.68..19.68 rows=1 width=16) (actual time=0.042..0.042 rows=1 loops=2)

181. 0.024 0.080 ↑ 1.0 1 2

Sort (cost=19.68..19.68 rows=1 width=16) (actual time=0.040..0.040 rows=1 loops=2)

  • Sort Key: lr_1.created_at DESC
  • Sort Method: quicksort Memory: 25kB
182. 0.056 0.056 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans lr_1 (cost=0.43..19.67 rows=1 width=16) (actual time=0.018..0.028 rows=10 loops=2)

  • Index Cond: (customer_id = customers.id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2))
  • Rows Removed by Filter: 12
183. 0.002 0.028 ↓ 0.0 0 2

Limit (cost=19.68..19.68 rows=1 width=16) (actual time=0.014..0.014 rows=0 loops=2)

184. 0.012 0.026 ↓ 0.0 0 2

Sort (cost=19.68..19.68 rows=1 width=16) (actual time=0.013..0.013 rows=0 loops=2)

  • Sort Key: lr_2.created_at DESC
  • Sort Method: quicksort Memory: 25kB
185. 0.014 0.014 ↓ 2.0 2 2

Index Scan using loans_customer_id_index on loans lr_2 (cost=0.43..19.67 rows=1 width=16) (actual time=0.005..0.007 rows=2 loops=2)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2))
  • Rows Removed by Filter: 0
186. 0.002 0.084 ↑ 1.0 1 2

Limit (cost=40.47..40.47 rows=1 width=16) (actual time=0.042..0.042 rows=1 loops=2)

187. 0.018 0.082 ↑ 3.0 1 2

Sort (cost=40.47..40.48 rows=3 width=16) (actual time=0.041..0.041 rows=1 loops=2)

  • Sort Key: lr_3.created_at DESC
  • Sort Method: quicksort Memory: 25kB
188. 0.064 0.064 ↓ 4.0 12 2

Index Scan using loans_customer_id_index on loans lr_3 (cost=0.43..40.46 rows=3 width=16) (actual time=0.019..0.032 rows=12 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (decision = 2))
  • Rows Removed by Filter: 12
189. 0.002 0.082 ↑ 1.0 1 2

Limit (cost=19.68..19.68 rows=1 width=16) (actual time=0.041..0.041 rows=1 loops=2)

190. 0.018 0.080 ↑ 1.0 1 2

Sort (cost=19.68..19.68 rows=1 width=16) (actual time=0.040..0.040 rows=1 loops=2)

  • Sort Key: lr_4.created_at DESC
  • Sort Method: quicksort Memory: 25kB
191. 0.062 0.062 ↑ 1.0 1 2

Index Scan using loans_customer_id_index on loans lr_4 (cost=0.43..19.67 rows=1 width=16) (actual time=0.028..0.031 rows=1 loops=2)

  • Index Cond: (customer_id = customers.id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15))
  • Rows Removed by Filter: 20
192. 0.002 0.026 ↓ 0.0 0 2

Limit (cost=19.68..19.68 rows=1 width=16) (actual time=0.012..0.013 rows=0 loops=2)

193. 0.012 0.024 ↓ 0.0 0 2

Sort (cost=19.68..19.68 rows=1 width=16) (actual time=0.012..0.012 rows=0 loops=2)

  • Sort Key: lr_5.created_at DESC
  • Sort Method: quicksort Memory: 25kB
194. 0.012 0.012 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans lr_5 (cost=0.43..19.67 rows=1 width=16) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15))
  • Rows Removed by Filter: 2
195. 0.002 0.092 ↑ 1.0 1 2

Limit (cost=40.47..40.47 rows=1 width=16) (actual time=0.046..0.046 rows=1 loops=2)

196. 0.026 0.090 ↑ 1.0 1 2

Sort (cost=40.47..40.47 rows=1 width=16) (actual time=0.045..0.045 rows=1 loops=2)

  • Sort Key: lr_6.created_at DESC
  • Sort Method: quicksort Memory: 25kB
197. 0.064 0.064 ↑ 1.0 1 2

Index Scan using loans_customer_id_index on loans lr_6 (cost=0.43..40.46 rows=1 width=16) (actual time=0.025..0.032 rows=1 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (status = 15))
  • Rows Removed by Filter: 23
198. 0.002 0.058 ↑ 1.0 1 2

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.029..0.029 rows=1 loops=2)

199. 0.056 0.056 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_7 (cost=0.43..19.71 rows=1 width=8) (actual time=0.028..0.028 rows=0 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '1 mon'::interval)))
  • Rows Removed by Filter: 22
200. 0.004 0.024 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.011..0.012 rows=1 loops=2)

201. 0.020 0.020 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust (cost=0.43..6.45 rows=1 width=8) (actual time=0.010..0.010 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
202. 0.002 0.014 ↑ 1.0 1 1

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=1)

203. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_8 (cost=0.43..19.71 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '1 mon'::interval)))
  • Rows Removed by Filter: 5
204. 0.008 0.028 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=2)

205. 0.020 0.020 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_1 (cost=0.43..12.19 rows=1 width=8) (actual time=0.007..0.010 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
206. 0.006 0.070 ↑ 1.0 1 2

Aggregate (cost=40.54..40.55 rows=1 width=8) (actual time=0.035..0.035 rows=1 loops=2)

207. 0.064 0.064 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_9 (cost=0.43..40.54 rows=1 width=8) (actual time=0.032..0.032 rows=0 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '1 mon'::interval)))
  • Rows Removed by Filter: 24
208. 0.004 0.056 ↑ 1.0 1 2

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.028..0.028 rows=1 loops=2)

209. 0.052 0.052 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_10 (cost=0.43..19.71 rows=1 width=8) (actual time=0.017..0.026 rows=0 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '3 mons'::interval)))
  • Rows Removed by Filter: 21
210. 0.004 0.014 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=2)

211. 0.010 0.010 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_2 (cost=0.43..6.45 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
212. 0.001 0.013 ↑ 1.0 1 1

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=1)

213. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_11 (cost=0.43..19.71 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '3 mons'::interval)))
  • Rows Removed by Filter: 5
214. 0.010 0.028 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=2)

215. 0.018 0.018 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_3 (cost=0.43..12.19 rows=1 width=8) (actual time=0.006..0.009 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
216. 0.008 0.070 ↑ 1.0 1 2

Aggregate (cost=40.54..40.55 rows=1 width=8) (actual time=0.035..0.035 rows=1 loops=2)

217. 0.062 0.062 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_12 (cost=0.43..40.54 rows=1 width=8) (actual time=0.019..0.031 rows=0 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '3 mons'::interval)))
  • Rows Removed by Filter: 24
218. 0.004 0.060 ↑ 1.0 1 2

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.030..0.030 rows=1 loops=2)

219. 0.056 0.056 ↑ 1.0 1 2

Index Scan using loans_customer_id_index on loans rl_13 (cost=0.43..19.71 rows=1 width=8) (actual time=0.019..0.028 rows=1 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '6 mons'::interval)))
  • Rows Removed by Filter: 20
220. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

221. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_4 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
222. 0.001 0.013 ↑ 1.0 1 1

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=1)

223. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_14 (cost=0.43..19.71 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '6 mons'::interval)))
  • Rows Removed by Filter: 5
224. 0.006 0.028 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=2)

225. 0.022 0.022 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_5 (cost=0.43..12.19 rows=1 width=8) (actual time=0.008..0.011 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
226. 0.006 0.070 ↑ 1.0 1 2

Aggregate (cost=40.54..40.55 rows=1 width=8) (actual time=0.035..0.035 rows=1 loops=2)

227. 0.064 0.064 ↑ 1.0 1 2

Index Scan using loans_customer_id_index on loans rl_15 (cost=0.43..40.54 rows=1 width=8) (actual time=0.019..0.032 rows=1 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (decision = 2) AND (created_at > (loans.created_at - '6 mons'::interval)))
  • Rows Removed by Filter: 23
228. 0.004 0.054 ↑ 1.0 1 2

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.027..0.027 rows=1 loops=2)

229. 0.050 0.050 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_16 (cost=0.43..19.71 rows=1 width=8) (actual time=0.025..0.025 rows=0 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '1 mon'::interval)))
  • Rows Removed by Filter: 22
230. 0.002 0.010 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=2)

231. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_6 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
232. 0.002 0.014 ↑ 1.0 1 1

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.013..0.014 rows=1 loops=1)

233. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_17 (cost=0.43..19.71 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '1 mon'::interval)))
  • Rows Removed by Filter: 5
234. 0.006 0.024 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=2)

235. 0.018 0.018 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_7 (cost=0.43..12.19 rows=1 width=8) (actual time=0.006..0.009 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
236. 0.004 0.066 ↑ 1.0 1 2

Aggregate (cost=40.54..40.55 rows=1 width=8) (actual time=0.033..0.033 rows=1 loops=2)

237. 0.062 0.062 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_18 (cost=0.43..40.54 rows=1 width=8) (actual time=0.031..0.031 rows=0 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '1 mon'::interval)))
  • Rows Removed by Filter: 24
238. 0.002 0.052 ↑ 1.0 1 2

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.026..0.026 rows=1 loops=2)

239. 0.050 0.050 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_19 (cost=0.43..19.71 rows=1 width=8) (actual time=0.025..0.025 rows=0 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '3 mons'::interval)))
  • Rows Removed by Filter: 22
240. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

241. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_8 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
242. 0.001 0.016 ↑ 1.0 1 1

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.016..0.016 rows=1 loops=1)

243. 0.015 0.015 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_20 (cost=0.43..19.71 rows=1 width=8) (actual time=0.015..0.015 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '3 mons'::interval)))
  • Rows Removed by Filter: 5
244. 0.008 0.026 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=2)

245. 0.018 0.018 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_9 (cost=0.43..12.19 rows=1 width=8) (actual time=0.007..0.009 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
246. 0.006 0.072 ↑ 1.0 1 2

Aggregate (cost=40.54..40.55 rows=1 width=8) (actual time=0.036..0.036 rows=1 loops=2)

247. 0.066 0.066 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_21 (cost=0.43..40.54 rows=1 width=8) (actual time=0.033..0.033 rows=0 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '3 mons'::interval)))
  • Rows Removed by Filter: 24
248. 0.004 0.060 ↑ 1.0 1 2

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.030..0.030 rows=1 loops=2)

249. 0.056 0.056 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_22 (cost=0.43..19.71 rows=1 width=8) (actual time=0.028..0.028 rows=0 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '6 mons'::interval)))
  • Rows Removed by Filter: 22
250. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

251. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_10 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
252. 0.001 0.014 ↑ 1.0 1 1

Aggregate (cost=19.71..19.72 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=1)

253. 0.013 0.013 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_23 (cost=0.43..19.71 rows=1 width=8) (actual time=0.013..0.013 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '6 mons'::interval)))
  • Rows Removed by Filter: 5
254. 0.010 0.028 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=2)

255. 0.018 0.018 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_11 (cost=0.43..12.19 rows=1 width=8) (actual time=0.006..0.009 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
256. 0.006 0.068 ↑ 1.0 1 2

Aggregate (cost=40.54..40.55 rows=1 width=8) (actual time=0.034..0.034 rows=1 loops=2)

257. 0.062 0.062 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans rl_24 (cost=0.43..40.54 rows=1 width=8) (actual time=0.031..0.031 rows=0 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((decision_date < loans.created_at) AND (status = 15) AND (created_at > (loans.created_at - '6 mons'::interval)))
  • Rows Removed by Filter: 24
258. 0.006 0.166 ↑ 1.0 1 2

Aggregate (cost=31.90..31.91 rows=1 width=8) (actual time=0.083..0.083 rows=1 loops=2)

259. 0.006 0.160 ↓ 8.0 8 2

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=8) (actual time=0.024..0.080 rows=8 loops=2)

260. 0.054 0.054 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans lf (cost=0.43..19.67 rows=1 width=8) (actual time=0.012..0.027 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 12
261. 0.100 0.100 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_24 (cost=0.42..6.52 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=20)

  • Index Cond: (lf.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
262. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

263. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_12 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
264. 0.001 0.014 ↑ 1.0 1 1

Aggregate (cost=31.90..31.91 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=1)

265. 0.001 0.013 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=8) (actual time=0.013..0.013 rows=0 loops=1)

266. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans lf_1 (cost=0.43..19.67 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 5
267. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_25 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_1.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
268. 0.006 0.134 ↑ 1.0 1 2

Aggregate (cost=59.22..59.23 rows=1 width=8) (actual time=0.067..0.067 rows=1 loops=2)

269. 0.020 0.128 ↓ 4.0 8 2

Nested Loop Anti Join (cost=0.86..59.21 rows=2 width=8) (actual time=0.024..0.064 rows=8 loops=2)

270. 0.068 0.068 ↓ 5.0 10 2

Index Scan using loans_customer_id_index on loans lf_2 (cost=0.43..40.46 rows=2 width=8) (actual time=0.016..0.034 rows=10 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 14
271. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_26 (cost=0.42..6.52 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (lf_2.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
272. 0.006 0.778 ↑ 1.0 1 2

Aggregate (cost=1,305.59..1,305.60 rows=1 width=8) (actual time=0.389..0.389 rows=1 loops=2)

273. 0.010 0.772 ↓ 7.0 7 2

Nested Loop Anti Join (cost=0.86..1,305.58 rows=1 width=8) (actual time=0.141..0.386 rows=7 loops=2)

274. 0.250 0.720 ↓ 7.0 7 2

Index Scan using loans_customer_id_index on loans lf_3 (cost=0.43..1,293.35 rows=1 width=8) (actual time=0.132..0.360 rows=7 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < loans.created_at) AND (status = 5) AND (GREATEST((SubPlan 90), (SubPlan 92)) < 1) AND ((date_trunc('day'::text, CASE WHEN (alternatives: SubPlan 83 or hashed SubPlan 84) THEN (SubPlan 86) ELSE settledate END))::date <= (date_trunc('day'::text, COALESCE((SubPlan 88), duedate)))::date))
  • Rows Removed by Filter: 14
275.          

SubPlan (for Index Scan)

276. 0.020 0.120 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l (cost=7.00..13.02 rows=1 width=4) (actual time=0.006..0.006 rows=1 loops=20)

  • Index Cond: (id = COALESCE($181, lf_3.id))
277.          

Initplan (for Index Scan)

278. 0.100 0.100 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_33 (cost=0.42..6.44 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_3.id)
279. 0.000 0.160 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.008..0.008 rows=1 loops=20)

280.          

Initplan (for Aggregate)

281. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_34 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_3.id)
282. 0.016 0.140 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.007..0.007 rows=0 loops=20)

283. 0.080 0.100 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=20)

  • Group Key: prolong_history_35.to_loan_id
284. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_35 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $183)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
285. 0.024 0.024 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_5 (cost=0.56..6.58 rows=1 width=12) (actual time=0.008..0.008 rows=1 loops=3)

  • Index Cond: (id = prolong_history_35.to_loan_id)
286. 0.075 0.075 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_27 (cost=0.42..8.62 rows=5 width=0) (actual time=0.005..0.005 rows=0 loops=15)

  • Index Cond: (origin_id = lf_3.id)
  • Filter: (deleted_at IS NULL)
287. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_28 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
288. 0.000 0.025 ↓ 0.0 0 1

Limit (cost=48.04..48.04 rows=1 width=16) (actual time=0.025..0.025 rows=0 loops=1)

289.          

Initplan (for Limit)

290. 0.010 0.010 ↓ 0.0 0 1

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_29 (cost=0.42..6.44 rows=1 width=8) (actual time=0.010..0.010 rows=0 loops=1)

  • Index Cond: (to_loan_id = lf_3.id)
291. 0.008 0.025 ↓ 0.0 0 1

Sort (cost=41.59..41.61 rows=5 width=16) (actual time=0.025..0.025 rows=0 loops=1)

  • Sort Key: l1_11.created_at DESC
  • Sort Method: quicksort Memory: 25kB
292. 0.001 0.017 ↓ 0.0 0 1

Nested Loop (cost=9.19..41.57 rows=5 width=16) (actual time=0.017..0.017 rows=0 loops=1)

293. 0.011 0.016 ↓ 0.0 0 1

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.016..0.016 rows=0 loops=1)

  • Group Key: prolong_history_30.to_loan_id
294. 0.005 0.005 ↓ 0.0 0 1

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_30 (cost=0.42..8.62 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=1)

  • Index Cond: (origin_id = $175)
  • Filter: (deleted_at IS NULL)
295. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_11 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_30.to_loan_id)
296. 0.000 0.090 ↑ 1.0 1 15

Aggregate (cost=48.02..48.03 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=15)

297.          

Initplan (for Aggregate)

298. 0.030 0.030 ↓ 0.0 0 15

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_31 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=15)

  • Index Cond: (to_loan_id = lf_3.id)
299. 0.008 0.075 ↓ 0.0 0 15

Nested Loop (cost=9.19..41.57 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=15)

300. 0.045 0.060 ↓ 0.0 0 15

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=15)

  • Group Key: prolong_history_32.to_loan_id
301. 0.015 0.015 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_32 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=15)

  • Index Cond: (origin_id = $178)
  • Filter: (deleted_at IS NULL)
302. 0.007 0.007 ↑ 1.0 1 1

Index Scan using loans_pkey on loans l1_12 (cost=0.56..6.58 rows=1 width=16) (actual time=0.007..0.007 rows=1 loops=1)

  • Index Cond: (id = prolong_history_32.to_loan_id)
303. 0.042 0.042 ↓ 0.0 0 14

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_36 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=14)

  • Index Cond: (lf_3.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
304. 0.004 0.016 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.007..0.008 rows=1 loops=2)

305. 0.012 0.012 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_13 (cost=0.43..6.45 rows=1 width=8) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
306. 0.002 0.019 ↑ 1.0 1 1

Aggregate (cost=1,305.59..1,305.60 rows=1 width=8) (actual time=0.018..0.019 rows=1 loops=1)

307. 0.004 0.017 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.86..1,305.58 rows=1 width=8) (actual time=0.017..0.017 rows=0 loops=1)

308. 0.013 0.013 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans lf_4 (cost=0.43..1,293.35 rows=1 width=8) (actual time=0.013..0.013 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 102), (SubPlan 104)) < 1) AND ((date_trunc('day'::text, CASE WHEN (alternatives: SubPlan 95 or hashed SubPlan 96) THEN (SubPlan 98) ELSE settledate END))::date <= (date_trunc('day'::text, COALESCE((SubPlan 100), duedate)))::date))
  • Rows Removed by Filter: 5
309.          

SubPlan (for Index Scan)

310. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l_1 (cost=7.00..13.02 rows=1 width=4) (never executed)

  • Index Cond: (id = COALESCE($199, lf_4.id))
311.          

Initplan (for Index Scan)

312. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_43 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_4.id)
313. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=48.02..48.03 rows=1 width=4) (never executed)

314.          

Initplan (for Aggregate)

315. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_44 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_4.id)
316. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=4) (never executed)

317. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_45.to_loan_id
318. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_45 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $201)
  • Filter: (deleted_at IS NULL)
319. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_6 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_45.to_loan_id)
320. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_37 (cost=0.42..8.62 rows=5 width=0) (never executed)

  • Index Cond: (origin_id = lf_4.id)
  • Filter: (deleted_at IS NULL)
321. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_38 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
322. 0.000 0.000 ↓ 0.0 0

Limit (cost=48.04..48.04 rows=1 width=16) (never executed)

323.          

Initplan (for Limit)

324. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_39 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_4.id)
325. 0.000 0.000 ↓ 0.0 0

Sort (cost=41.59..41.61 rows=5 width=16) (never executed)

  • Sort Key: l1_13.created_at DESC
326. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=16) (never executed)

327. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_40.to_loan_id
328. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_40 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $193)
  • Filter: (deleted_at IS NULL)
329. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_13 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_40.to_loan_id)
330. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=48.02..48.03 rows=1 width=8) (never executed)

331.          

Initplan (for Aggregate)

332. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_41 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_4.id)
333. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=8) (never executed)

334. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_42.to_loan_id
335. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_42 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $196)
  • Filter: (deleted_at IS NULL)
336. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_14 (cost=0.56..6.58 rows=1 width=16) (never executed)

  • Index Cond: (id = prolong_history_42.to_loan_id)
337. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_46 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_4.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
338. 0.008 0.642 ↑ 1.0 1 2

Aggregate (cost=2,759.27..2,759.28 rows=1 width=8) (actual time=0.321..0.321 rows=1 loops=2)

339. 0.014 0.634 ↓ 7.0 7 2

Nested Loop Anti Join (cost=0.86..2,759.27 rows=1 width=8) (actual time=0.126..0.317 rows=7 loops=2)

340. 0.199 0.578 ↓ 7.0 7 2

Index Scan using loans_customer_id_index on loans lf_5 (cost=0.43..2,747.03 rows=1 width=8) (actual time=0.114..0.289 rows=7 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 113), (SubPlan 115)) < 1) AND ((date_trunc('day'::text, CASE WHEN (alternatives: SubPlan 106 or hashed SubPlan 107) THEN (SubPlan 109) ELSE settledate END))::date <= (date_trunc('day'::text, COALESCE((SubPlan 111), duedate)))::date))
  • Rows Removed by Filter: 17
341.          

SubPlan (for Index Scan)

342. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_2 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($216, lf_5.id))
343.          

Initplan (for Index Scan)

344. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_53 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_5.id)
345. 0.000 0.140 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=20)

346.          

Initplan (for Aggregate)

347. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_54 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_5.id)
348. 0.025 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

349. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_55.to_loan_id
350. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_55 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $218)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
351. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_7 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_55.to_loan_id)
352. 0.045 0.045 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_47 (cost=0.42..8.62 rows=5 width=0) (actual time=0.003..0.003 rows=0 loops=15)

  • Index Cond: (origin_id = lf_5.id)
  • Filter: (deleted_at IS NULL)
353. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_48 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
354. 0.000 0.024 ↓ 0.0 0 1

Limit (cost=48.04..48.04 rows=1 width=16) (actual time=0.024..0.024 rows=0 loops=1)

355.          

Initplan (for Limit)

356. 0.007 0.007 ↓ 0.0 0 1

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_49 (cost=0.42..6.44 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=1)

  • Index Cond: (to_loan_id = lf_5.id)
357. 0.011 0.024 ↓ 0.0 0 1

Sort (cost=41.59..41.61 rows=5 width=16) (actual time=0.024..0.024 rows=0 loops=1)

  • Sort Key: l1_15.created_at DESC
  • Sort Method: quicksort Memory: 25kB
358. 0.001 0.013 ↓ 0.0 0 1

Nested Loop (cost=9.19..41.57 rows=5 width=16) (actual time=0.013..0.013 rows=0 loops=1)

359. 0.009 0.012 ↓ 0.0 0 1

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Group Key: prolong_history_50.to_loan_id
360. 0.003 0.003 ↓ 0.0 0 1

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_50 (cost=0.42..8.62 rows=5 width=8) (actual time=0.003..0.003 rows=0 loops=1)

  • Index Cond: (origin_id = $210)
  • Filter: (deleted_at IS NULL)
361. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_15 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_50.to_loan_id)
362. 0.000 0.090 ↑ 1.0 1 15

Aggregate (cost=48.02..48.03 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=15)

363.          

Initplan (for Aggregate)

364. 0.030 0.030 ↓ 0.0 0 15

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_51 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=15)

  • Index Cond: (to_loan_id = lf_5.id)
365. 0.004 0.075 ↓ 0.0 0 15

Nested Loop (cost=9.19..41.57 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=15)

366. 0.045 0.060 ↓ 0.0 0 15

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=15)

  • Group Key: prolong_history_52.to_loan_id
367. 0.015 0.015 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_52 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=15)

  • Index Cond: (origin_id = $213)
  • Filter: (deleted_at IS NULL)
368. 0.011 0.011 ↑ 1.0 1 1

Index Scan using loans_pkey on loans l1_16 (cost=0.56..6.58 rows=1 width=16) (actual time=0.011..0.011 rows=1 loops=1)

  • Index Cond: (id = prolong_history_52.to_loan_id)
369. 0.042 0.042 ↓ 0.0 0 14

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_56 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=14)

  • Index Cond: (lf_5.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
370. 0.006 0.126 ↑ 1.0 1 2

Aggregate (cost=31.90..31.91 rows=1 width=8) (actual time=0.063..0.063 rows=1 loops=2)

371. 0.018 0.120 ↓ 8.0 8 2

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=8) (actual time=0.021..0.060 rows=8 loops=2)

372. 0.062 0.062 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans lf_6 (cost=0.43..19.67 rows=1 width=8) (actual time=0.015..0.031 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 12
373. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_57 (cost=0.42..6.52 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (lf_6.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
374. 0.006 0.606 ↑ 1.0 1 2

Aggregate (cost=1,305.57..1,305.58 rows=1 width=8) (actual time=0.303..0.303 rows=1 loops=2)

375. 0.011 0.600 ↓ 6.0 6 2

Nested Loop Anti Join (cost=0.86..1,305.56 rows=1 width=8) (actual time=0.121..0.300 rows=6 loops=2)

376. 0.176 0.556 ↓ 6.0 6 2

Index Scan using loans_customer_id_index on loans lf_7 (cost=0.43..1,293.33 rows=1 width=8) (actual time=0.112..0.278 rows=6 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 125), (SubPlan 127)) < 1) AND ((date(CASE WHEN (alternatives: SubPlan 118 or hashed SubPlan 119) THEN (SubPlan 121) ELSE settledate END) - date(COALESCE((SubPlan 123), duedate))) <= '-3'::integer))
  • Rows Removed by Filter: 16
377.          

SubPlan (for Index Scan)

378. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_3 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($238, lf_7.id))
379.          

Initplan (for Index Scan)

380. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_64 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_7.id)
381. 0.000 0.140 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=20)

382.          

Initplan (for Aggregate)

383. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_65 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_7.id)
384. 0.005 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

385. 0.080 0.100 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=20)

  • Group Key: prolong_history_66.to_loan_id
386. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_66 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $240)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
387. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_8 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_66.to_loan_id)
388. 0.045 0.045 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_58 (cost=0.42..8.62 rows=5 width=0) (actual time=0.003..0.003 rows=0 loops=15)

  • Index Cond: (origin_id = lf_7.id)
  • Filter: (deleted_at IS NULL)
389. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_59 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
390. 0.000 0.025 ↓ 0.0 0 1

Limit (cost=48.04..48.04 rows=1 width=16) (actual time=0.025..0.025 rows=0 loops=1)

391.          

Initplan (for Limit)

392. 0.007 0.007 ↓ 0.0 0 1

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_60 (cost=0.42..6.44 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=1)

  • Index Cond: (to_loan_id = lf_7.id)
393. 0.012 0.025 ↓ 0.0 0 1

Sort (cost=41.59..41.61 rows=5 width=16) (actual time=0.025..0.025 rows=0 loops=1)

  • Sort Key: l1_17.created_at DESC
  • Sort Method: quicksort Memory: 25kB
394. 0.000 0.013 ↓ 0.0 0 1

Nested Loop (cost=9.19..41.57 rows=5 width=16) (actual time=0.013..0.013 rows=0 loops=1)

395. 0.010 0.013 ↓ 0.0 0 1

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.012..0.013 rows=0 loops=1)

  • Group Key: prolong_history_61.to_loan_id
396. 0.003 0.003 ↓ 0.0 0 1

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_61 (cost=0.42..8.62 rows=5 width=8) (actual time=0.003..0.003 rows=0 loops=1)

  • Index Cond: (origin_id = $232)
  • Filter: (deleted_at IS NULL)
397. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_17 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_61.to_loan_id)
398. 0.000 0.090 ↑ 1.0 1 15

Aggregate (cost=48.02..48.03 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=15)

399.          

Initplan (for Aggregate)

400. 0.045 0.045 ↓ 0.0 0 15

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_62 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=15)

  • Index Cond: (to_loan_id = lf_7.id)
401. 0.008 0.075 ↓ 0.0 0 15

Nested Loop (cost=9.19..41.57 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=15)

402. 0.045 0.060 ↓ 0.0 0 15

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=15)

  • Group Key: prolong_history_63.to_loan_id
403. 0.015 0.015 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_63 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=15)

  • Index Cond: (origin_id = $235)
  • Filter: (deleted_at IS NULL)
404. 0.007 0.007 ↑ 1.0 1 1

Index Scan using loans_pkey on loans l1_18 (cost=0.56..6.58 rows=1 width=16) (actual time=0.007..0.007 rows=1 loops=1)

  • Index Cond: (id = prolong_history_63.to_loan_id)
405. 0.033 0.033 ↓ 0.0 0 11

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_67 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=11)

  • Index Cond: (lf_7.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
406. 0.008 0.138 ↑ 1.0 1 2

Aggregate (cost=31.90..31.91 rows=1 width=8) (actual time=0.069..0.069 rows=1 loops=2)

407. 0.000 0.130 ↓ 8.0 8 2

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=0) (actual time=0.026..0.065 rows=8 loops=2)

408. 0.070 0.070 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans lf_8 (cost=0.43..19.67 rows=1 width=8) (actual time=0.019..0.035 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 12
409. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_68 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (lf_8.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
410. 0.004 0.018 ↑ 1.0 1 2

Aggregate (cost=31.90..31.91 rows=1 width=8) (actual time=0.009..0.009 rows=1 loops=2)

411. 0.002 0.014 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=2)

412. 0.012 0.012 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans lf_9 (cost=0.43..19.67 rows=1 width=8) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 2
413. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_69 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_9.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
414. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=1,305.57..1,305.58 rows=1 width=8) (never executed)

415. 0.000 0.000 ↓ 0.0 0

Nested Loop Anti Join (cost=0.86..1,305.56 rows=1 width=8) (never executed)

416. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_customer_id_index on loans lf_10 (cost=0.43..1,293.33 rows=1 width=8) (never executed)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 138), (SubPlan 140)) < 1) AND ((date(CASE WHEN (alternatives: SubPlan 131 or hashed SubPlan 132) THEN (SubPlan 134) ELSE settledate END) - date(COALESCE((SubPlan 136), duedate))) <= '-3'::integer))
417.          

SubPlan (for Index Scan)

418. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l_4 (cost=7.00..13.02 rows=1 width=4) (never executed)

  • Index Cond: (id = COALESCE($263, lf_10.id))
419.          

Initplan (for Index Scan)

420. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_76 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_10.id)
421. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=48.02..48.03 rows=1 width=4) (never executed)

422.          

Initplan (for Aggregate)

423. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_77 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_10.id)
424. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=4) (never executed)

425. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_78.to_loan_id
426. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_78 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $265)
  • Filter: (deleted_at IS NULL)
427. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_9 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_78.to_loan_id)
428. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_70 (cost=0.42..8.62 rows=5 width=0) (never executed)

  • Index Cond: (origin_id = lf_10.id)
  • Filter: (deleted_at IS NULL)
429. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_71 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
430. 0.000 0.000 ↓ 0.0 0

Limit (cost=48.04..48.04 rows=1 width=16) (never executed)

431.          

Initplan (for Limit)

432. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_72 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_10.id)
433. 0.000 0.000 ↓ 0.0 0

Sort (cost=41.59..41.61 rows=5 width=16) (never executed)

  • Sort Key: l1_19.created_at DESC
434. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=16) (never executed)

435. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_73.to_loan_id
436. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_73 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $257)
  • Filter: (deleted_at IS NULL)
437. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_19 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_73.to_loan_id)
438. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=48.02..48.03 rows=1 width=8) (never executed)

439.          

Initplan (for Aggregate)

440. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_74 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_10.id)
441. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=8) (never executed)

442. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_75.to_loan_id
443. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_75 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $260)
  • Filter: (deleted_at IS NULL)
444. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_20 (cost=0.56..6.58 rows=1 width=16) (never executed)

  • Index Cond: (id = prolong_history_75.to_loan_id)
445. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_79 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_10.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
446. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=31.90..31.91 rows=1 width=8) (never executed)

447. 0.000 0.000 ↓ 0.0 0

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=0) (never executed)

448. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_customer_id_index on loans lf_11 (cost=0.43..19.67 rows=1 width=8) (never executed)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
449. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_80 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_11.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
450. 0.008 0.132 ↑ 1.0 1 2

Aggregate (cost=59.22..59.23 rows=1 width=8) (actual time=0.066..0.066 rows=1 loops=2)

451. 0.018 0.124 ↓ 4.0 8 2

Nested Loop Anti Join (cost=0.86..59.21 rows=2 width=8) (actual time=0.023..0.062 rows=8 loops=2)

452. 0.066 0.066 ↓ 5.0 10 2

Index Scan using loans_customer_id_index on loans lf_12 (cost=0.43..40.46 rows=2 width=8) (actual time=0.014..0.033 rows=10 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 14
453. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_81 (cost=0.42..6.52 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (lf_12.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
454. 0.006 0.618 ↑ 1.0 1 2

Aggregate (cost=2,759.23..2,759.24 rows=1 width=8) (actual time=0.309..0.309 rows=1 loops=2)

455. 0.013 0.612 ↓ 6.0 6 2

Nested Loop Anti Join (cost=0.86..2,759.22 rows=1 width=8) (actual time=0.124..0.306 rows=6 loops=2)

456. 0.189 0.566 ↓ 6.0 6 2

Index Scan using loans_customer_id_index on loans lf_13 (cost=0.43..2,746.99 rows=1 width=8) (actual time=0.113..0.283 rows=6 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 151), (SubPlan 153)) < 1) AND ((date(CASE WHEN (alternatives: SubPlan 144 or hashed SubPlan 145) THEN (SubPlan 147) ELSE settledate END) - date(COALESCE((SubPlan 149), duedate))) <= '-3'::integer))
  • Rows Removed by Filter: 18
457.          

SubPlan (for Index Scan)

458. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_5 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($289, lf_13.id))
459.          

Initplan (for Index Scan)

460. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_88 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_13.id)
461. 0.000 0.140 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=20)

462.          

Initplan (for Aggregate)

463. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_89 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_13.id)
464. 0.025 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

465. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_90.to_loan_id
466. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_90 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $291)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
467. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_10 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_90.to_loan_id)
468. 0.045 0.045 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_82 (cost=0.42..8.62 rows=5 width=0) (actual time=0.003..0.003 rows=0 loops=15)

  • Index Cond: (origin_id = lf_13.id)
  • Filter: (deleted_at IS NULL)
469. 0.000 0.000 ↓ 0.0 0

Seq Scan on prolong_history prolong_history_83 (cost=0.00..16,842.74 rows=506,998 width=8) (never executed)

  • Filter: (deleted_at IS NULL)
470. 0.000 0.022 ↓ 0.0 0 1

Limit (cost=48.04..48.04 rows=1 width=16) (actual time=0.022..0.022 rows=0 loops=1)

471.          

Initplan (for Limit)

472. 0.007 0.007 ↓ 0.0 0 1

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_84 (cost=0.42..6.44 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=1)

  • Index Cond: (to_loan_id = lf_13.id)
473. 0.007 0.021 ↓ 0.0 0 1

Sort (cost=41.59..41.61 rows=5 width=16) (actual time=0.021..0.021 rows=0 loops=1)

  • Sort Key: l1_21.created_at DESC
  • Sort Method: quicksort Memory: 25kB
474. 0.001 0.014 ↓ 0.0 0 1

Nested Loop (cost=9.19..41.57 rows=5 width=16) (actual time=0.014..0.014 rows=0 loops=1)

475. 0.009 0.013 ↓ 0.0 0 1

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.013..0.013 rows=0 loops=1)

  • Group Key: prolong_history_85.to_loan_id
476. 0.004 0.004 ↓ 0.0 0 1

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_85 (cost=0.42..8.62 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=1)

  • Index Cond: (origin_id = $283)
  • Filter: (deleted_at IS NULL)
477. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l1_21 (cost=0.56..6.58 rows=1 width=24) (never executed)

  • Index Cond: (id = prolong_history_85.to_loan_id)
478. 0.000 0.090 ↑ 1.0 1 15

Aggregate (cost=48.02..48.03 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=15)

479.          

Initplan (for Aggregate)

480. 0.030 0.030 ↓ 0.0 0 15

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_86 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=15)

  • Index Cond: (to_loan_id = lf_13.id)
481. 0.007 0.075 ↓ 0.0 0 15

Nested Loop (cost=9.19..41.57 rows=5 width=8) (actual time=0.005..0.005 rows=0 loops=15)

482. 0.045 0.060 ↓ 0.0 0 15

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=15)

  • Group Key: prolong_history_87.to_loan_id
483. 0.015 0.015 ↓ 0.0 0 15

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_87 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=15)

  • Index Cond: (origin_id = $286)
  • Filter: (deleted_at IS NULL)
484. 0.008 0.008 ↑ 1.0 1 1

Index Scan using loans_pkey on loans l1_22 (cost=0.56..6.58 rows=1 width=16) (actual time=0.008..0.008 rows=1 loops=1)

  • Index Cond: (id = prolong_history_87.to_loan_id)
485. 0.033 0.033 ↓ 0.0 0 11

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_91 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=11)

  • Index Cond: (lf_13.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
486. 0.008 0.144 ↑ 1.0 1 2

Aggregate (cost=59.22..59.23 rows=1 width=8) (actual time=0.072..0.072 rows=1 loops=2)

487. 0.006 0.136 ↓ 4.0 8 2

Nested Loop Anti Join (cost=0.86..59.21 rows=2 width=0) (actual time=0.026..0.068 rows=8 loops=2)

488. 0.070 0.070 ↓ 5.0 10 2

Index Scan using loans_customer_id_index on loans lf_14 (cost=0.43..40.46 rows=2 width=8) (actual time=0.016..0.035 rows=10 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 14
489. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_92 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (lf_14.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
490. 0.004 0.382 ↑ 1.0 1 2

Aggregate (cost=520.38..520.39 rows=1 width=8) (actual time=0.191..0.191 rows=1 loops=2)

491. 0.004 0.378 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..520.38 rows=1 width=0) (actual time=0.163..0.189 rows=0 loops=2)

492. 0.164 0.364 ↑ 1.0 1 2

Index Scan using loans_customer_id_index on loans lf_15 (cost=0.43..508.14 rows=1 width=8) (actual time=0.157..0.182 rows=1 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 157), (SubPlan 159)) > 3))
  • Rows Removed by Filter: 20
493.          

SubPlan (for Index Scan)

494. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_6 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($304, lf_15.id))
495.          

Initplan (for Index Scan)

496. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_93 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_15.id)
497. 0.000 0.120 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.006..0.006 rows=1 loops=20)

498.          

Initplan (for Aggregate)

499. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_94 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_15.id)
500. 0.025 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

501. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_95.to_loan_id
502. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_95 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $306)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
503. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_11 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_95.to_loan_id)
504. 0.010 0.010 ↓ 0.0 0 2

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_96 (cost=0.42..6.52 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Index Cond: (lf_15.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
505. 0.004 0.014 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=2)

506. 0.010 0.010 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_14 (cost=0.43..6.45 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
507. 0.001 0.015 ↑ 1.0 1 1

Aggregate (cost=520.38..520.39 rows=1 width=8) (actual time=0.015..0.015 rows=1 loops=1)

508. 0.002 0.014 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.86..520.38 rows=1 width=0) (actual time=0.014..0.014 rows=0 loops=1)

509. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans lf_16 (cost=0.43..508.14 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 163), (SubPlan 165)) > 3))
  • Rows Removed by Filter: 5
510.          

SubPlan (for Index Scan)

511. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l_7 (cost=7.00..13.02 rows=1 width=4) (never executed)

  • Index Cond: (id = COALESCE($315, lf_16.id))
512.          

Initplan (for Index Scan)

513. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_97 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_16.id)
514. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=48.02..48.03 rows=1 width=4) (never executed)

515.          

Initplan (for Aggregate)

516. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_98 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_16.id)
517. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=4) (never executed)

518. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_99.to_loan_id
519. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_99 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $317)
  • Filter: (deleted_at IS NULL)
520. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_12 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_99.to_loan_id)
521. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_100 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_16.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
522. 0.004 0.434 ↑ 1.0 1 2

Aggregate (cost=1,090.71..1,090.72 rows=1 width=8) (actual time=0.217..0.217 rows=1 loops=2)

523. 0.010 0.430 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..1,090.70 rows=1 width=0) (actual time=0.181..0.215 rows=0 loops=2)

524. 0.166 0.406 ↑ 1.0 1 2

Index Scan using loans_customer_id_index on loans lf_17 (cost=0.43..1,078.47 rows=1 width=8) (actual time=0.171..0.203 rows=1 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 168), (SubPlan 170)) > 3))
  • Rows Removed by Filter: 23
525.          

SubPlan (for Index Scan)

526. 0.040 0.100 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_8 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.005 rows=1 loops=20)

  • Index Cond: (id = COALESCE($324, lf_17.id))
527.          

Initplan (for Index Scan)

528. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_101 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_17.id)
529. 0.000 0.140 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=20)

530.          

Initplan (for Aggregate)

531. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_102 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_17.id)
532. 0.025 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

533. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_103.to_loan_id
534. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_103 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $326)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
535. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_13 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_103.to_loan_id)
536. 0.014 0.014 ↓ 0.0 0 2

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_104 (cost=0.42..6.52 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=2)

  • Index Cond: (lf_17.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
537. 0.002 0.376 ↑ 1.0 1 2

Aggregate (cost=520.38..520.39 rows=1 width=8) (actual time=0.188..0.188 rows=1 loops=2)

538. 0.004 0.374 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..520.38 rows=1 width=0) (actual time=0.187..0.187 rows=0 loops=2)

539. 0.150 0.370 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans lf_18 (cost=0.43..508.14 rows=1 width=8) (actual time=0.185..0.185 rows=0 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 173), (SubPlan 175)) > 30))
  • Rows Removed by Filter: 22
540.          

SubPlan (for Index Scan)

541. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_9 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($334, lf_18.id))
542.          

Initplan (for Index Scan)

543. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_105 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_18.id)
544. 0.000 0.140 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.006..0.007 rows=1 loops=20)

545.          

Initplan (for Aggregate)

546. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_106 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_18.id)
547. 0.022 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

548. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_107.to_loan_id
549. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_107 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $336)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
550. 0.018 0.018 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_14 (cost=0.56..6.58 rows=1 width=12) (actual time=0.006..0.006 rows=1 loops=3)

  • Index Cond: (id = prolong_history_107.to_loan_id)
551. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_108 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_18.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
552. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

553. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_15 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
554. 0.002 0.016 ↑ 1.0 1 1

Aggregate (cost=520.38..520.39 rows=1 width=8) (actual time=0.015..0.016 rows=1 loops=1)

555. 0.002 0.014 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.86..520.38 rows=1 width=0) (actual time=0.014..0.014 rows=0 loops=1)

556. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans lf_19 (cost=0.43..508.14 rows=1 width=8) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 179), (SubPlan 181)) > 30))
  • Rows Removed by Filter: 5
557.          

SubPlan (for Index Scan)

558. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l_10 (cost=7.00..13.02 rows=1 width=4) (never executed)

  • Index Cond: (id = COALESCE($345, lf_19.id))
559.          

Initplan (for Index Scan)

560. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_109 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_19.id)
561. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=48.02..48.03 rows=1 width=4) (never executed)

562.          

Initplan (for Aggregate)

563. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_110 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_19.id)
564. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=4) (never executed)

565. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_111.to_loan_id
566. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_111 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $347)
  • Filter: (deleted_at IS NULL)
567. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_15 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_111.to_loan_id)
568. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_112 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_19.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
569. 0.004 0.392 ↑ 1.0 1 2

Aggregate (cost=1,090.71..1,090.72 rows=1 width=8) (actual time=0.196..0.196 rows=1 loops=2)

570. 0.008 0.388 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..1,090.70 rows=1 width=0) (actual time=0.194..0.194 rows=0 loops=2)

571. 0.180 0.380 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans lf_20 (cost=0.43..1,078.47 rows=1 width=8) (actual time=0.190..0.190 rows=0 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 184), (SubPlan 186)) > 30))
  • Rows Removed by Filter: 24
572.          

SubPlan (for Index Scan)

573. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_11 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($354, lf_20.id))
574.          

Initplan (for Index Scan)

575. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_113 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_20.id)
576. 0.000 0.120 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.006..0.006 rows=1 loops=20)

577.          

Initplan (for Aggregate)

578. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_114 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_20.id)
579. 0.025 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

580. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_115.to_loan_id
581. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_115 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $356)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
582. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_16 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_115.to_loan_id)
583. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_116 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_20.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
584. 0.004 0.374 ↑ 1.0 1 2

Aggregate (cost=520.38..520.39 rows=1 width=8) (actual time=0.187..0.187 rows=1 loops=2)

585. 0.004 0.370 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..520.38 rows=1 width=0) (actual time=0.185..0.185 rows=0 loops=2)

586. 0.166 0.366 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans lf_21 (cost=0.43..508.14 rows=1 width=8) (actual time=0.183..0.183 rows=0 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 189), (SubPlan 191)) > 60))
  • Rows Removed by Filter: 22
587.          

SubPlan (for Index Scan)

588. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_12 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($364, lf_21.id))
589.          

Initplan (for Index Scan)

590. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_117 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_21.id)
591. 0.000 0.120 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.006..0.006 rows=1 loops=20)

592.          

Initplan (for Aggregate)

593. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_118 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_21.id)
594. 0.025 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

595. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_119.to_loan_id
596. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_119 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $366)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
597. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_17 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_119.to_loan_id)
598. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_120 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_21.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
599. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

600. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_16 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
601. 0.002 0.017 ↑ 1.0 1 1

Aggregate (cost=520.38..520.39 rows=1 width=8) (actual time=0.017..0.017 rows=1 loops=1)

602. 0.001 0.015 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.86..520.38 rows=1 width=0) (actual time=0.015..0.015 rows=0 loops=1)

603. 0.014 0.014 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans lf_22 (cost=0.43..508.14 rows=1 width=8) (actual time=0.014..0.014 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 195), (SubPlan 197)) > 60))
  • Rows Removed by Filter: 5
604.          

SubPlan (for Index Scan)

605. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l_13 (cost=7.00..13.02 rows=1 width=4) (never executed)

  • Index Cond: (id = COALESCE($375, lf_22.id))
606.          

Initplan (for Index Scan)

607. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_121 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_22.id)
608. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=48.02..48.03 rows=1 width=4) (never executed)

609.          

Initplan (for Aggregate)

610. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_122 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = lf_22.id)
611. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.57 rows=5 width=4) (never executed)

612. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_123.to_loan_id
613. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_123 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = $377)
  • Filter: (deleted_at IS NULL)
614. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans prolong_loans_18 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_123.to_loan_id)
615. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_124 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_22.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
616. 0.002 0.390 ↑ 1.0 1 2

Aggregate (cost=1,090.71..1,090.72 rows=1 width=8) (actual time=0.195..0.195 rows=1 loops=2)

617. 0.008 0.388 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..1,090.70 rows=1 width=0) (actual time=0.194..0.194 rows=0 loops=2)

618. 0.180 0.380 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans lf_23 (cost=0.43..1,078.47 rows=1 width=8) (actual time=0.190..0.190 rows=0 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5) AND (GREATEST((SubPlan 200), (SubPlan 202)) > 60))
  • Rows Removed by Filter: 24
619.          

SubPlan (for Index Scan)

620. 0.020 0.080 ↑ 1.0 1 20

Index Scan using loans_pkey on loans l_14 (cost=7.00..13.02 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: (id = COALESCE($384, lf_23.id))
621.          

Initplan (for Index Scan)

622. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_125 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_23.id)
623. 0.000 0.120 ↑ 1.0 1 20

Aggregate (cost=48.02..48.03 rows=1 width=4) (actual time=0.006..0.006 rows=1 loops=20)

624.          

Initplan (for Aggregate)

625. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_126 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = lf_23.id)
626. 0.025 0.120 ↓ 0.0 0 20

Nested Loop (cost=9.19..41.57 rows=5 width=4) (actual time=0.006..0.006 rows=0 loops=20)

627. 0.060 0.080 ↓ 0.0 0 20

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=20)

  • Group Key: prolong_history_127.to_loan_id
628. 0.020 0.020 ↓ 0.0 0 20

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_127 (cost=0.42..8.62 rows=5 width=8) (actual time=0.001..0.001 rows=0 loops=20)

  • Index Cond: (origin_id = $386)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
629. 0.015 0.015 ↑ 1.0 1 3

Index Scan using loans_pkey on loans prolong_loans_19 (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=3)

  • Index Cond: (id = prolong_history_127.to_loan_id)
630. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_128 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (lf_23.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
631. 0.008 0.074 ↑ 1.0 1 2

Aggregate (cost=19.65..19.66 rows=1 width=4) (actual time=0.037..0.037 rows=1 loops=2)

632. 0.066 0.066 ↓ 6.7 20 2

Index Scan using loans_customer_id_index on loans lf_24 (cost=0.43..19.65 rows=3 width=4) (actual time=0.012..0.033 rows=20 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: (created_at < loans.created_at)
  • Rows Removed by Filter: 1
633. 0.004 0.016 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=2)

634. 0.012 0.012 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_17 (cost=0.43..6.45 rows=1 width=8) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
635. 0.001 0.015 ↑ 1.0 1 1

Aggregate (cost=19.67..19.68 rows=1 width=4) (actual time=0.015..0.015 rows=1 loops=1)

636. 0.014 0.014 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans l2 (cost=0.43..19.67 rows=1 width=4) (actual time=0.014..0.014 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 5
637. 0.008 0.028 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=2)

638. 0.020 0.020 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_18 (cost=0.43..12.19 rows=1 width=8) (actual time=0.007..0.010 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
639. 0.008 0.072 ↑ 1.0 1 2

Aggregate (cost=40.46..40.47 rows=1 width=4) (actual time=0.036..0.036 rows=1 loops=2)

640. 0.064 0.064 ↓ 5.0 10 2

Index Scan using loans_customer_id_index on loans l2_1 (cost=0.43..40.46 rows=2 width=4) (actual time=0.014..0.032 rows=10 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 14
641. 0.000 0.208 ↑ 1.0 1 2

Aggregate (cost=93.12..93.13 rows=1 width=4) (actual time=0.104..0.104 rows=1 loops=2)

642.          

Initplan (for Aggregate)

643. 0.000 0.014 ↓ 0.0 0 2

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_130 (cost=32.34..38.36 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=2)

  • Index Cond: (to_loan_id = $410)
644.          

Initplan (for Index Scan)

645. 0.004 0.150 ↑ 1.0 1 2

Limit (cost=31.91..31.92 rows=1 width=16) (actual time=0.074..0.075 rows=1 loops=2)

646. 0.022 0.146 ↑ 1.0 1 2

Sort (cost=31.91..31.92 rows=1 width=16) (actual time=0.073..0.073 rows=1 loops=2)

  • Sort Key: lf_25.created_at DESC
  • Sort Method: top-N heapsort Memory: 25kB
647. 0.004 0.124 ↓ 8.0 8 2

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=16) (actual time=0.022..0.062 rows=8 loops=2)

648. 0.060 0.060 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans lf_25 (cost=0.43..19.67 rows=1 width=16) (actual time=0.014..0.030 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < loans.created_at) AND (status = 5))
  • Rows Removed by Filter: 12
649. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_129 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (lf_25.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
650. 0.004 0.204 ↑ 7.0 1 2

Nested Loop (cost=9.20..54.75 rows=7 width=4) (actual time=0.098..0.102 rows=1 loops=2)

651. 0.176 0.184 ↑ 7.0 1 2

HashAggregate (cost=8.64..8.71 rows=7 width=8) (actual time=0.092..0.092 rows=1 loops=2)

  • Group Key: pr_hi.to_loan_id
652. 0.008 0.008 ↑ 7.0 1 2

Index Scan using prolong_history_origin_id_index on prolong_history pr_hi (cost=0.42..8.62 rows=7 width=8) (actual time=0.004..0.004 rows=1 loops=2)

  • Index Cond: (origin_id = $411)
653. 0.016 0.016 ↑ 1.0 1 2

Index Scan using loans_pkey on loans rl_25 (cost=0.56..6.58 rows=1 width=12) (actual time=0.008..0.008 rows=1 loops=2)

  • Index Cond: (id = pr_hi.to_loan_id)
654. 0.004 0.172 ↑ 1.0 1 2

Limit (cost=32.14..32.14 rows=1 width=12) (actual time=0.085..0.086 rows=1 loops=2)

655. 0.022 0.168 ↑ 1.0 1 2

Sort (cost=32.14..32.14 rows=1 width=12) (actual time=0.084..0.084 rows=1 loops=2)

  • Sort Key: lf_26.created_at DESC
  • Sort Method: top-N heapsort Memory: 25kB
656. 0.006 0.146 ↓ 8.0 8 2

Nested Loop Anti Join (cost=0.86..32.13 rows=1 width=12) (actual time=0.031..0.073 rows=8 loops=2)

657. 0.080 0.080 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans lf_26 (cost=0.43..19.67 rows=1 width=20) (actual time=0.023..0.040 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < loans.created_at) AND (status = 5))
  • Rows Removed by Filter: 12
658. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_131 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (lf_26.id = to_loan_id)
  • Filter: (deleted_at IS NULL)
659. 0.004 0.034 ↓ 0.0 0 2

Limit (cost=32.14..73.75 rows=1 width=12) (actual time=0.017..0.017 rows=0 loops=2)

660. 0.002 0.030 ↓ 0.0 0 2

Result (cost=32.14..73.75 rows=1 width=12) (actual time=0.015..0.015 rows=0 loops=2)

661. 0.014 0.028 ↓ 0.0 0 2

Sort (cost=32.14..32.14 rows=1 width=20) (actual time=0.014..0.014 rows=0 loops=2)

  • Sort Key: l2_2.settledate DESC NULLS LAST
  • Sort Method: quicksort Memory: 25kB
662. 0.002 0.014 ↓ 0.0 0 2

Nested Loop Anti Join (cost=0.86..32.13 rows=1 width=20) (actual time=0.007..0.007 rows=0 loops=2)

663. 0.012 0.012 ↓ 0.0 0 2

Index Scan using loans_customer_id_index on loans l2_2 (cost=0.43..19.67 rows=1 width=20) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 2
664. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_133 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = l2_2.id)
  • Filter: (deleted_at IS NULL)
665.          

SubPlan (for Result)

666. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=41.59..41.60 rows=1 width=4) (never executed)

667. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=9.19..41.58 rows=2 width=4) (never executed)

668. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=8.63..8.68 rows=5 width=8) (never executed)

  • Group Key: prolong_history_132.to_loan_id
669. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_132 (cost=0.42..8.62 rows=5 width=8) (never executed)

  • Index Cond: (origin_id = l2_2.id)
  • Filter: (deleted_at IS NULL)
670. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans l3 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = prolong_history_132.to_loan_id)
  • Filter: (settledate < loans.created_at)
671. 0.006 0.200 ↑ 1.0 1 2

Limit (cost=59.37..100.98 rows=1 width=12) (actual time=0.099..0.100 rows=1 loops=2)

672. 0.006 0.194 ↑ 2.0 1 2

Result (cost=59.37..142.59 rows=2 width=12) (actual time=0.097..0.097 rows=1 loops=2)

673. 0.016 0.152 ↑ 2.0 1 2

Sort (cost=59.37..59.37 rows=2 width=20) (actual time=0.076..0.076 rows=1 loops=2)

  • Sort Key: l2_3.settledate DESC NULLS LAST
  • Sort Method: top-N heapsort Memory: 25kB
674. 0.024 0.136 ↓ 4.0 8 2

Nested Loop Anti Join (cost=0.86..59.36 rows=2 width=20) (actual time=0.024..0.068 rows=8 loops=2)

675. 0.072 0.072 ↓ 5.0 10 2

Index Scan using loans_customer_id_index on loans l2_3 (cost=0.43..40.46 rows=2 width=20) (actual time=0.016..0.036 rows=10 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 14
676. 0.040 0.040 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_135 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=20)

  • Index Cond: (to_loan_id = l2_3.id)
  • Filter: (deleted_at IS NULL)
677.          

SubPlan (for Result)

678. 0.004 0.036 ↑ 1.0 1 2

Aggregate (cost=41.59..41.60 rows=1 width=4) (actual time=0.018..0.018 rows=1 loops=2)

679. 0.003 0.032 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.58 rows=2 width=4) (actual time=0.015..0.016 rows=0 loops=2)

680. 0.004 0.020 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.010..0.010 rows=0 loops=2)

  • Group Key: prolong_history_134.to_loan_id
681. 0.016 0.016 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_134 (cost=0.42..8.62 rows=5 width=8) (actual time=0.007..0.008 rows=0 loops=2)

  • Index Cond: (origin_id = l2_3.id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
682. 0.009 0.009 ↑ 1.0 1 1

Index Scan using loans_pkey on loans l3_1 (cost=0.56..6.58 rows=1 width=12) (actual time=0.009..0.009 rows=1 loops=1)

  • Index Cond: (id = prolong_history_134.to_loan_id)
  • Filter: (settledate < loans.created_at)
683. 0.006 0.212 ↑ 1.0 1 2

Limit (cost=31.91..79.97 rows=1 width=12) (actual time=0.104..0.106 rows=1 loops=2)

684. 0.008 0.206 ↑ 1.0 1 2

Result (cost=31.91..79.97 rows=1 width=12) (actual time=0.103..0.103 rows=1 loops=2)

685. 0.026 0.156 ↑ 1.0 1 2

Sort (cost=31.91..31.92 rows=1 width=32) (actual time=0.078..0.078 rows=1 loops=2)

  • Sort Key: rl_26.created_at DESC
  • Sort Method: top-N heapsort Memory: 25kB
686. 0.006 0.130 ↓ 8.0 8 2

Nested Loop Anti Join (cost=0.86..31.90 rows=1 width=32) (actual time=0.023..0.065 rows=8 loops=2)

687. 0.064 0.064 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans rl_26 (cost=0.43..19.67 rows=1 width=32) (actual time=0.015..0.032 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((settledate < loans.created_at) AND (status = 5))
  • Rows Removed by Filter: 12
688. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_138 (cost=0.42..6.52 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (rl_26.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
689.          

SubPlan (for Result)

690. 0.000 0.042 ↑ 1.0 1 2

Aggregate (cost=48.02..48.03 rows=1 width=8) (actual time=0.021..0.021 rows=1 loops=2)

691.          

Initplan (for Aggregate)

692. 0.012 0.012 ↓ 0.0 0 2

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_136 (cost=0.42..6.44 rows=1 width=8) (actual time=0.006..0.006 rows=0 loops=2)

  • Index Cond: (to_loan_id = rl_26.id)
693. 0.004 0.038 ↓ 0.0 0 2

Nested Loop (cost=9.19..41.57 rows=5 width=8) (actual time=0.019..0.019 rows=0 loops=2)

694. 0.018 0.026 ↓ 0.0 0 2

HashAggregate (cost=8.63..8.68 rows=5 width=8) (actual time=0.013..0.013 rows=0 loops=2)

  • Group Key: prolong_history_137.to_loan_id
695. 0.008 0.008 ↓ 0.0 0 2

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_137 (cost=0.42..8.62 rows=5 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (origin_id = $430)
  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 0
696. 0.008 0.008 ↑ 1.0 1 1

Index Scan using loans_pkey on loans l1_23 (cost=0.56..6.58 rows=1 width=16) (actual time=0.008..0.008 rows=1 loops=1)

  • Index Cond: (id = prolong_history_137.to_loan_id)
697. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

698. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_19 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
699. 0.001 0.026 ↓ 0.0 0 1

Limit (cost=31.92..31.92 rows=1 width=12) (actual time=0.026..0.026 rows=0 loops=1)

700. 0.010 0.025 ↓ 0.0 0 1

Sort (cost=31.92..31.92 rows=1 width=12) (actual time=0.025..0.025 rows=0 loops=1)

  • Sort Key: rl_27.settledate DESC
  • Sort Method: quicksort Memory: 25kB
701. 0.001 0.015 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.86..31.91 rows=1 width=12) (actual time=0.015..0.015 rows=0 loops=1)

702. 0.014 0.014 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_27 (cost=0.43..19.67 rows=1 width=24) (actual time=0.014..0.014 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 5
703. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_139 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (rl_27.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
704. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

705. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_20 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
706. 0.000 0.018 ↓ 0.0 0 1

Limit (cost=31.92..31.92 rows=1 width=12) (actual time=0.018..0.018 rows=0 loops=1)

707. 0.006 0.018 ↓ 0.0 0 1

Sort (cost=31.92..31.92 rows=1 width=12) (actual time=0.018..0.018 rows=0 loops=1)

  • Sort Key: rl_28.settledate DESC
  • Sort Method: quicksort Memory: 25kB
708. 0.001 0.012 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.86..31.91 rows=1 width=12) (actual time=0.012..0.012 rows=0 loops=1)

709. 0.011 0.011 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans rl_28 (cost=0.43..19.67 rows=1 width=24) (actual time=0.011..0.011 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 5
710. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_from_loan_id_index on prolong_history prolong_history_140 (cost=0.42..6.52 rows=1 width=8) (never executed)

  • Index Cond: (rl_28.id = from_loan_id)
  • Filter: (deleted_at IS NULL)
711. 0.000 0.150 ↑ 1.0 1 2

Aggregate (cost=22.60..22.61 rows=1 width=4) (actual time=0.075..0.075 rows=1 loops=2)

712.          

Initplan (for Aggregate)

713. 0.014 0.014 ↑ 1.0 1 2

Seq Scan on locations loc_3 (cost=0.00..1.41 rows=1 width=14) (actual time=0.006..0.007 rows=1 loops=2)

  • Filter: (id = loans.location_id)
  • Rows Removed by Filter: 32
714. 0.010 0.010 ↑ 1.0 1 2

Seq Scan on locations loc_4 (cost=0.00..1.41 rows=1 width=14) (actual time=0.004..0.005 rows=1 loops=2)

  • Filter: (id = loans.location_id)
  • Rows Removed by Filter: 32
715. 0.144 0.144 ↓ 7.0 14 2

Index Scan using loans_customer_id_index on loans l2_4 (cost=0.43..19.77 rows=2 width=4) (actual time=0.032..0.072 rows=14 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((created_at < loans.created_at) AND ((timezone(($448)::text, timezone('UTC'::text, settledate)) > (timezone(($449)::text, timezone('UTC'::text, loans.created_at)) - '6 mons'::interval)) OR (settledate IS NULL)))
  • Rows Removed by Filter: 8
716. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

717. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_21 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
718. 0.001 0.013 ↑ 1.0 1 1

Aggregate (cost=19.69..19.70 rows=1 width=4) (actual time=0.013..0.013 rows=1 loops=1)

719. 0.012 0.012 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans l2_5 (cost=0.43..19.69 rows=2 width=4) (actual time=0.012..0.012 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND ((settledate > (loans.created_at - '6 mons'::interval)) OR (settledate IS NULL)))
  • Rows Removed by Filter: 5
720. 0.010 0.030 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.015..0.015 rows=1 loops=2)

721. 0.020 0.020 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_22 (cost=0.43..12.19 rows=1 width=8) (actual time=0.007..0.010 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
722. 0.008 0.074 ↑ 1.0 1 2

Aggregate (cost=40.51..40.52 rows=1 width=4) (actual time=0.037..0.037 rows=1 loops=2)

723. 0.066 0.066 ↑ 1.7 3 2

Index Scan using loans_customer_id_index on loans l2_6 (cost=0.43..40.50 rows=5 width=4) (actual time=0.026..0.033 rows=3 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND ((settledate > (loans.created_at - '6 mons'::interval)) OR (settledate IS NULL)))
  • Rows Removed by Filter: 21
724. 0.000 0.138 ↑ 1.0 1 2

Aggregate (cost=22.60..22.61 rows=1 width=4) (actual time=0.069..0.069 rows=1 loops=2)

725.          

Initplan (for Aggregate)

726. 0.012 0.012 ↑ 1.0 1 2

Seq Scan on locations loc_5 (cost=0.00..1.41 rows=1 width=14) (actual time=0.004..0.006 rows=1 loops=2)

  • Filter: (id = loans.location_id)
  • Rows Removed by Filter: 32
727. 0.010 0.010 ↑ 1.0 1 2

Seq Scan on locations loc_6 (cost=0.00..1.41 rows=1 width=14) (actual time=0.004..0.005 rows=1 loops=2)

  • Filter: (id = loans.location_id)
  • Rows Removed by Filter: 32
728. 0.130 0.130 ↓ 8.0 16 2

Index Scan using loans_customer_id_index on loans l2_7 (cost=0.43..19.77 rows=2 width=4) (actual time=0.029..0.065 rows=16 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((created_at < loans.created_at) AND ((timezone(($465)::text, timezone('UTC'::text, settledate)) > (timezone(($466)::text, timezone('UTC'::text, loans.created_at)) - '1 year'::interval)) OR (settledate IS NULL)))
  • Rows Removed by Filter: 6
729. 0.004 0.012 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=2)

730. 0.008 0.008 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_23 (cost=0.43..6.45 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
731. 0.001 0.014 ↑ 1.0 1 1

Aggregate (cost=19.69..19.70 rows=1 width=4) (actual time=0.014..0.014 rows=1 loops=1)

732. 0.013 0.013 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans l2_8 (cost=0.43..19.69 rows=2 width=4) (actual time=0.013..0.013 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND ((settledate > (loans.created_at - '1 year'::interval)) OR (settledate IS NULL)))
  • Rows Removed by Filter: 5
733. 0.008 0.026 ↑ 1.0 1 2

Aggregate (cost=12.19..12.20 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=2)

734. 0.018 0.018 ↓ 2.0 2 2

Index Scan using customers_pkey on customers cust_24 (cost=0.43..12.19 rows=1 width=8) (actual time=0.007..0.009 rows=2 loops=2)

  • Index Cond: (id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: (created_at < loans.created_at)
735. 0.010 0.076 ↑ 1.0 1 2

Aggregate (cost=40.51..40.52 rows=1 width=4) (actual time=0.037..0.038 rows=1 loops=2)

736. 0.066 0.066 ↓ 1.2 6 2

Index Scan using loans_customer_id_index on loans l2_9 (cost=0.43..40.50 rows=5 width=4) (actual time=0.025..0.033 rows=6 loops=2)

  • Index Cond: (customer_id = ANY (ARRAY[cl.id, loans.customer_id]))
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND ((settledate > (loans.created_at - '1 year'::interval)) OR (settledate IS NULL)))
  • Rows Removed by Filter: 18
737. 0.027 0.434 ↑ 1.0 1 2

Aggregate (cost=99.96..99.97 rows=1 width=32) (actual time=0.217..0.217 rows=1 loops=2)

738. 0.016 0.288 ↓ 8.0 8 2

Nested Loop (cost=39.14..45.17 rows=1 width=12) (actual time=0.108..0.144 rows=8 loops=2)

739. 0.008 0.204 ↓ 8.0 8 2

Unique (cost=38.58..38.59 rows=1 width=8) (actual time=0.099..0.102 rows=8 loops=2)

740. 0.026 0.196 ↓ 8.0 8 2

Sort (cost=38.58..38.58 rows=1 width=8) (actual time=0.097..0.098 rows=8 loops=2)

  • Sort Key: (COALESCE((SubPlan 239), l2_10.id))
  • Sort Method: quicksort Memory: 25kB
741. 0.012 0.170 ↓ 8.0 8 2

Nested Loop Anti Join (cost=0.86..38.57 rows=1 width=8) (actual time=0.029..0.085 rows=8 loops=2)

742. 0.064 0.064 ↓ 10.0 10 2

Index Scan using loans_customer_id_index on loans l2_10 (cost=0.43..19.67 rows=1 width=8) (actual time=0.015..0.032 rows=10 loops=2)

  • Index Cond: (customer_id = loans.customer_id)
  • Filter: ((created_at < loans.created_at) AND (status = 5))
  • Rows Removed by Filter: 12
743. 0.060 0.060 ↓ 0.0 0 20

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_143 (cost=0.42..6.44 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=20)

  • Index Cond: (l2_10.id = to_loan_id)
  • Filter: (deleted_at IS NULL)
744.          

SubPlan (for Nested Loop Anti Join)

745. 0.034 0.034 ↓ 0.0 0 17

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_142 (cost=0.42..6.44 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=17)

  • Index Cond: (to_loan_id = l2_10.id)
746. 0.068 0.068 ↑ 1.0 1 17

Index Scan using loans_pkey on loans loan_groups (cost=0.56..6.58 rows=1 width=12) (actual time=0.004..0.004 rows=1 loops=17)

  • Index Cond: (id = (COALESCE((SubPlan 239), l2_10.id)))
747.          

SubPlan (for Aggregate)

748. 0.017 0.119 ↑ 1.0 1 17

Aggregate (cost=54.77..54.78 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=17)

749. 0.014 0.102 ↓ 0.0 0 17

Nested Loop (cost=9.20..54.75 rows=7 width=4) (actual time=0.005..0.006 rows=0 loops=17)

750. 0.017 0.068 ↓ 0.0 0 17

HashAggregate (cost=8.64..8.71 rows=7 width=8) (actual time=0.004..0.004 rows=0 loops=17)

  • Group Key: prolong_history_141.to_loan_id
751. 0.051 0.051 ↓ 0.0 0 17

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_141 (cost=0.42..8.62 rows=7 width=8) (actual time=0.003..0.003 rows=0 loops=17)

  • Index Cond: (origin_id = loan_groups.id)
752. 0.020 0.020 ↑ 1.0 1 4

Index Scan using loans_pkey on loans plg (cost=0.56..6.58 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=4)

  • Index Cond: (id = prolong_history_141.to_loan_id)
753. 0.004 0.014 ↑ 1.0 1 2

Aggregate (cost=6.46..6.47 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=2)

754. 0.010 0.010 ↓ 0.0 0 2

Index Scan using customers_pkey on customers cust_25 (cost=0.43..6.45 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=2)

  • Index Cond: (id = cl.id)
  • Filter: (created_at < loans.created_at)
755. 0.004 0.027 ↑ 1.0 1 1

Aggregate (cost=155.34..155.35 rows=1 width=32) (actual time=0.026..0.027 rows=1 loops=1)

756. 0.001 0.023 ↓ 0.0 0 1

Nested Loop (cost=26.68..32.71 rows=1 width=12) (actual time=0.023..0.023 rows=0 loops=1)

757. 0.000 0.022 ↓ 0.0 0 1

Unique (cost=26.12..26.13 rows=1 width=8) (actual time=0.022..0.022 rows=0 loops=1)

758. 0.007 0.022 ↓ 0.0 0 1

Sort (cost=26.12..26.12 rows=1 width=8) (actual time=0.022..0.022 rows=0 loops=1)

  • Sort Key: (COALESCE((SubPlan 246), l2_11.id))
  • Sort Method: quicksort Memory: 25kB
759. 0.015 0.015 ↓ 0.0 0 1

Index Scan using loans_customer_id_index on loans l2_11 (cost=0.43..26.11 rows=1 width=8) (actual time=0.015..0.015 rows=0 loops=1)

  • Index Cond: (customer_id = cl.id)
  • Filter: ((settledate < COALESCE(loans.sas_execution, loans.created_at)) AND (status = 5))
  • Rows Removed by Filter: 5
760.          

SubPlan (for Index Scan)

761. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_to_loan_id_index on prolong_history prolong_history_146 (cost=0.42..6.44 rows=1 width=8) (never executed)

  • Index Cond: (to_loan_id = l2_11.id)
762. 0.000 0.000 ↓ 0.0 0

Index Scan using loans_pkey on loans loan_groups_1 (cost=0.56..6.58 rows=1 width=12) (never executed)

  • Index Cond: (id = (COALESCE((SubPlan 246), l2_11.id)))
763.          

SubPlan (for Aggregate)

764. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=61.30..61.31 rows=1 width=4) (never executed)

765. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=55.27..61.29 rows=1 width=8) (never executed)

766. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=54.71..54.72 rows=1 width=8) (never executed)

  • Group Key: prolong_history_144.to_loan_id
767. 0.000 0.000 ↓ 0.0 0

Limit (cost=54.69..54.69 rows=1 width=16) (never executed)

768. 0.000 0.000 ↓ 0.0 0

Sort (cost=54.69..54.69 rows=1 width=16) (never executed)

  • Sort Key: prolong_history_144.created_at DESC
769. 0.000 0.000 ↓ 0.0 0

Index Scan using prolong_history_origin_id_index on prolong_history prolong_history_144 (cost=0.42..54.68 rows=1 width=16) (never executed)

  • Index Cond: (origin_id = loan_groups_1.id)
  • Filter: ((deleted_at IS NULL) AND (created_at < COALESCE(loans.sas_execution, loans.created_at)) AND ((SubPlan 242) IS NULL))
770.          

SubPlan (for Index Scan)

771. 0.000 <