explain.depesz.com

PostgreSQL's explain analyze made readable

Result: WVlw

Settings
# exclusive inclusive rows x rows loops node
1. 0.059 134.828 ↓ 1.7 10 1

Sort (cost=75,411.25..75,411.26 rows=6 width=3,200) (actual time=134.827..134.828 rows=10 loops=1)

  • Sort Key: cash_receipt_scheduled_payment_line.customer_code, cash_receipt_scheduled_payment_line.line_type DESC, cash_receipt_scheduled_payment_line.transaction_type, cash_receipt_scheduled_payment_line.invoice_number, cash_receipt_scheduled_payment_line.purchase_order_number, cash_receipt_scheduled_payment_line.due_date, cash_receipt_scheduled_payment_line.invoice_amount
  • Sort Method: quicksort Memory: 27kB
2. 0.032 134.769 ↓ 1.7 10 1

HashAggregate (cost=75,411.05..75,411.11 rows=6 width=3,200) (actual time=134.764..134.769 rows=10 loops=1)

  • Group Key: cash_receipt_scheduled_payment_line.rnum, cash_receipt_scheduled_payment_line.id, cash_receipt_scheduled_payment_line.discount_amount, cash_receipt_scheduled_payment_line.discount_date, cash_receipt_scheduled_payment_line.due_date, cash_receipt_scheduled_payment_line.invoice_id, cash_receipt_scheduled_payment_line.invoice_amount, cash_receipt_scheduled_payment_line.invoice_date, cash_receipt_scheduled_payment_line.invoice_number, cash_receipt_scheduled_payment_line.refno_est, cash_receipt_scheduled_payment_line.misc_charge_amount, cash_receipt_scheduled_payment_line.gl_misc_charge_account, cash_receipt_scheduled_payment_line.description, cash_receipt_scheduled_payment_line.open_balance, cash_receipt_scheduled_payment_line.paid_amount, cash_receipt_scheduled_payment_line.discount_taken, cash_receipt_scheduled_payment_line.purchase_order_number, cash_receipt_scheduled_payment_line.scheduled_payment_status, cash_receipt_scheduled_payment_line.transaction_type, cash_receipt_scheduled_payment_line.customer_id, cash_receipt_scheduled_payment_line.customer_code, cash_receipt_scheduled_payment_line.customer_name, cash_receipt_scheduled_payment_line.applied_amount, cash_receipt_scheduled_payment_line.discount, cash_receipt_scheduled_payment_line.service_fee, cash_receipt_scheduled_payment_line.cash_receipt_line_id, cash_receipt_scheduled_payment_line.cash_receipt_head_id, cash_receipt_scheduled_payment_line.charge_back_id, cash_receipt_scheduled_payment_line.line_status, cash_receipt_scheduled_payment_line.line_type, cash_receipt_scheduled_payment_line.payment_number
3. 0.002 134.737 ↓ 1.7 10 1

Append (cost=18,186.26..75,410.58 rows=6 width=3,200) (actual time=67.759..134.737 rows=10 loops=1)

4. 0.150 34.338 ↓ 0.0 0 1

Subquery Scan on cash_receipt_scheduled_payment_line (cost=18,186.26..18,818.78 rows=1 width=4,132) (actual time=34.338..34.338 rows=0 loops=1)

  • Filter: (((cash_receipt_scheduled_payment_line.customer_id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text) AND (cash_receipt_scheduled_payment_line.cash_receipt_head_id = 'd98bf299-ad8e-4197-91b5-c04ed40fe392'::uuid) AND ((cash_receipt_scheduled_payment_line.applied_amount <> '0'::numeric) OR (cash_receipt_scheduled_payment_line.misc_charge_amount <> '0'::numeric)))
  • Rows Removed by Filter: 2,227
5. 1.016 34.188 ↑ 2.4 2,227 1

WindowAgg (cost=18,186.26..18,713.36 rows=5,271 width=4,132) (actual time=31.689..34.188 rows=2,227 loops=1)

6. 1.359 33.172 ↑ 2.4 2,227 1

Unique (cost=18,186.26..18,594.76 rows=5,271 width=4,124) (actual time=31.682..33.172 rows=2,227 loops=1)

7. 2.411 31.813 ↑ 2.4 2,227 1

Sort (cost=18,186.26..18,199.43 rows=5,271 width=4,124) (actual time=31.681..31.813 rows=2,227 loops=1)

  • Sort Key: a.id, a.discount_amount, a.discount_date, a.due_date, a.invoice_id, a.invoice_amount, a.invoice_date, a.invoice_number, (0.00), a.paid_amount, a.purchase_order_number, a.scheduled_payment_status, a.transaction_type, a.customer_id, (((((cg.code)::text || '-'::text) || (cu.code)::text))::character varying(255)), cu.name, b.applied_amount, b.discount, b.service_fee, b.id, b.cash_receipt_head_id, b.charge_back_id, b.line_status, b.line_type, c.payment_number, a.refno_est, b.misc_charge_amount, b.gl_misc_charge_account, b.description, a.discount_taken
  • Sort Method: quicksort Memory: 1,240kB
8. 0.202 29.402 ↑ 2.4 2,227 1

Append (cost=1,397.06..12,382.81 rows=5,271 width=4,124) (actual time=8.774..29.402 rows=2,227 loops=1)

9. 0.994 28.275 ↑ 1.5 2,207 1

Hash Left Join (cost=1,397.06..12,044.02 rows=3,232 width=870) (actual time=8.773..28.275 rows=2,207 loops=1)

  • Hash Cond: (b.cash_receipt_head_id = c.id)
10. 0.924 26.910 ↑ 1.5 2,207 1

Hash Left Join (cost=1,259.98..11,874.20 rows=3,232 width=322) (actual time=8.377..26.910 rows=2,207 loops=1)

  • Hash Cond: ((cu.customer_group)::text = (cg.id)::text)
11. 2.154 17.781 ↑ 1.5 2,207 1

Nested Loop (cost=0.84..10,606.59 rows=3,232 width=353) (actual time=0.042..17.781 rows=2,207 loops=1)

12. 1.531 6.799 ↑ 1.7 2,207 1

Nested Loop (cost=0.43..8,955.14 rows=3,748 width=290) (actual time=0.025..6.799 rows=2,207 loops=1)

13. 0.814 0.814 ↑ 1.7 2,227 1

Seq Scan on cash_receipt_line b (cost=0.00..221.98 rows=3,748 width=125) (actual time=0.008..0.814 rows=2,227 loops=1)

  • Filter: (NOT deleted)
  • Rows Removed by Filter: 803
14. 4.454 4.454 ↑ 1.0 1 2,227

Index Scan using cash_receipt_scheduled_payment_pkey on cash_receipt_scheduled_payment a (cost=0.43..2.33 rows=1 width=181) (actual time=0.002..0.002 rows=1 loops=2,227)

  • Index Cond: (id = b.cash_receipt_scheduled_payment_id)
  • Filter: active
15. 8.828 8.828 ↑ 1.0 1 2,207

Index Scan using customer_pkey on customer cu (cost=0.41..0.44 rows=1 width=174) (actual time=0.004..0.004 rows=1 loops=2,207)

  • Index Cond: ((id)::text = (a.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
16. 3.764 8.205 ↑ 1.0 18,877 1

Hash (cost=1,015.17..1,015.17 rows=19,517 width=43) (actual time=8.205..8.205 rows=18,877 loops=1)

  • Buckets: 32,768 Batches: 1 Memory Usage: 1,656kB
17. 4.441 4.441 ↑ 1.0 18,877 1

Seq Scan on customer_group cg (cost=0.00..1,015.17 rows=19,517 width=43) (actual time=0.003..4.441 rows=18,877 loops=1)

18. 0.091 0.371 ↑ 4.3 517 1

Hash (cost=109.26..109.26 rows=2,226 width=25) (actual time=0.371..0.371 rows=517 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 62kB
19. 0.280 0.280 ↑ 4.3 517 1

Seq Scan on cash_receipt_head c (cost=0.00..109.26 rows=2,226 width=25) (actual time=0.004..0.280 rows=517 loops=1)

20. 0.199 0.925 ↑ 102.0 20 1

Hash Join (cost=29.64..286.07 rows=2,039 width=2,548) (actual time=0.343..0.925 rows=20 loops=1)

  • Hash Cond: (b_1.charge_back_id = a_1.id)
21. 0.451 0.451 ↑ 1.7 3,030 1

Seq Scan on cash_receipt_line b_1 (cost=0.00..221.98 rows=5,098 width=69) (actual time=0.004..0.451 rows=3,030 loops=1)

22. 0.013 0.275 ↓ 5.0 20 1

Hash (cost=29.59..29.59 rows=4 width=1,660) (actual time=0.275..0.275 rows=20 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 12kB
23. 0.018 0.262 ↓ 5.0 20 1

Nested Loop (cost=2.38..29.59 rows=4 width=1,660) (actual time=0.043..0.262 rows=20 loops=1)

24. 0.012 0.224 ↓ 5.0 20 1

Nested Loop Left Join (cost=2.10..20.48 rows=4 width=1,672) (actual time=0.038..0.224 rows=20 loops=1)

25. 0.016 0.132 ↓ 5.0 20 1

Nested Loop (cost=1.69..18.65 rows=4 width=1,703) (actual time=0.028..0.132 rows=20 loops=1)

26. 0.011 0.016 ↓ 4.0 20 1

Bitmap Heap Scan on charge_back a_1 (cost=1.27..5.47 rows=5 width=1,640) (actual time=0.011..0.016 rows=20 loops=1)

  • Filter: (NOT deleted)
  • Heap Blocks: exact=1
27. 0.005 0.005 ↓ 4.0 20 1

Bitmap Index Scan on idx_charge_back_deleted (cost=0.00..1.27 rows=5 width=0) (actual time=0.005..0.005 rows=20 loops=1)

  • Index Cond: (deleted = false)
28. 0.100 0.100 ↑ 1.0 1 20

Index Scan using customer_pkey on customer cu_1 (cost=0.41..2.64 rows=1 width=174) (actual time=0.005..0.005 rows=1 loops=20)

  • Index Cond: ((id)::text = (a_1.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
29. 0.080 0.080 ↑ 1.0 1 20

Index Scan using customer_group_pkey on customer_group cg_1 (cost=0.41..0.46 rows=1 width=43) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: ((id)::text = (cu_1.customer_group)::text)
30. 0.020 0.020 ↑ 1.0 1 20

Index Scan using cash_receipt_head_pkey on cash_receipt_head c_1 (cost=0.28..2.28 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=20)

  • Index Cond: (id = a_1.cash_receipt_head_id)
31. 0.020 33.566 ↓ 3.3 10 1

WindowAgg (cost=18,770.73..18,954.04 rows=3 width=1,080) (actual time=33.421..33.566 rows=10 loops=1)

32. 0.006 33.546 ↓ 3.3 10 1

Nested Loop (cost=18,770.73..18,953.98 rows=3 width=213) (actual time=33.411..33.546 rows=10 loops=1)

33. 0.004 0.030 ↑ 1.0 1 1

Nested Loop Left Join (cost=0.83..5.27 rows=1 width=69) (actual time=0.029..0.030 rows=1 loops=1)

34. 0.016 0.016 ↑ 1.0 1 1

Index Scan using customer_pkey on customer cu_2 (cost=0.41..2.64 rows=1 width=174) (actual time=0.015..0.016 rows=1 loops=1)

  • Index Cond: ((id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text)
  • Filter: (ar_location = 'T'::bpchar)
35. 0.010 0.010 ↑ 1.0 1 1

Index Scan using customer_group_pkey on customer_group cg_2 (cost=0.41..2.63 rows=1 width=43) (actual time=0.010..0.010 rows=1 loops=1)

  • Index Cond: ((id)::text = (cu_2.customer_group)::text)
36. 0.156 33.510 ↓ 3.3 10 1

Bitmap Heap Scan on cash_receipt_scheduled_payment cr (cost=18,769.90..18,948.69 rows=3 width=181) (actual time=33.379..33.510 rows=10 loops=1)

  • Recheck Cond: ((customer_id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text)
  • Filter: (active AND ((scheduled_payment_status)::text <> 'CLOSED'::text) AND (invoice_amount <> '0'::numeric) AND (invoice_date <= '2020-01-08'::date) AND (NOT (hashed SubPlan 2)))
  • Rows Removed by Filter: 482
  • Heap Blocks: exact=25
37. 0.053 0.053 ↓ 3.1 492 1

Bitmap Index Scan on idx_cash_receipt_scheduled_payment_customer_id (cost=0.00..3.83 rows=160 width=0) (actual time=0.053..0.053 rows=492 loops=1)

  • Index Cond: ((customer_id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text)
38.          

SubPlan (for Bitmap Heap Scan)

39. 0.126 33.301 ↓ 0.0 0 1

Subquery Scan on cash_receipt_scheduled_payment_line_3 (cost=18,186.26..18,766.07 rows=1 width=16) (actual time=33.301..33.301 rows=0 loops=1)

  • Filter: (((cash_receipt_scheduled_payment_line_3.line_status)::text = 'DRAFT'::text) AND ((cash_receipt_scheduled_payment_line_3.customer_id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text) AND ((cash_receipt_scheduled_payment_line_3.line_type)::text = 'SP'::text) AND ((cash_receipt_scheduled_payment_line_3.applied_amount <> '0'::numeric) OR (cash_receipt_scheduled_payment_line_3.misc_charge_amount <> '0'::numeric)))
  • Rows Removed by Filter: 2,227
40. 0.694 33.175 ↑ 2.4 2,227 1

Subquery Scan on v_1 (cost=18,186.26..18,647.47 rows=5,271 width=4,132) (actual time=31.320..33.175 rows=2,227 loops=1)

41. 1.031 32.481 ↑ 2.4 2,227 1

Unique (cost=18,186.26..18,594.76 rows=5,271 width=4,124) (actual time=31.318..32.481 rows=2,227 loops=1)

42. 2.354 31.450 ↑ 2.4 2,227 1

Sort (cost=18,186.26..18,199.43 rows=5,271 width=4,124) (actual time=31.317..31.450 rows=2,227 loops=1)

  • Sort Key: a_6.id, a_6.discount_amount, a_6.discount_date, a_6.due_date, a_6.invoice_id, a_6.invoice_amount, a_6.invoice_date, a_6.invoice_number, (0.00), a_6.paid_amount, a_6.purchase_order_number, a_6.scheduled_payment_status, a_6.transaction_type, a_6.customer_id, (((((cg_8.code)::text || '-'::text) || (cu_8.code)::text))::character varying(255)), cu_8.name, b_6.applied_amount, b_6.discount, b_6.service_fee, b_6.id, b_6.cash_receipt_head_id, b_6.charge_back_id, b_6.line_status, b_6.line_type, c_6.payment_number, a_6.refno_est, b_6.misc_charge_amount, b_6.gl_misc_charge_account, b_6.description, a_6.discount_taken
  • Sort Method: quicksort Memory: 1,240kB
43. 0.209 29.096 ↑ 2.4 2,227 1

Append (cost=1,397.06..12,382.81 rows=5,271 width=4,124) (actual time=8.953..29.096 rows=2,227 loops=1)

44. 1.008 28.112 ↑ 1.5 2,207 1

Hash Left Join (cost=1,397.06..12,044.02 rows=3,232 width=870) (actual time=8.952..28.112 rows=2,207 loops=1)

  • Hash Cond: (b_6.cash_receipt_head_id = c_6.id)
45. 0.917 26.746 ↑ 1.5 2,207 1

Hash Left Join (cost=1,259.98..11,874.20 rows=3,232 width=322) (actual time=8.561..26.746 rows=2,207 loops=1)

  • Hash Cond: ((cu_8.customer_group)::text = (cg_8.id)::text)
46. 2.062 17.431 ↑ 1.5 2,207 1

Nested Loop (cost=0.84..10,606.59 rows=3,232 width=353) (actual time=0.030..17.431 rows=2,207 loops=1)

47. 1.394 6.541 ↑ 1.7 2,207 1

Nested Loop (cost=0.43..8,955.14 rows=3,748 width=290) (actual time=0.015..6.541 rows=2,207 loops=1)

48. 0.693 0.693 ↑ 1.7 2,227 1

Seq Scan on cash_receipt_line b_6 (cost=0.00..221.98 rows=3,748 width=125) (actual time=0.005..0.693 rows=2,227 loops=1)

  • Filter: (NOT deleted)
  • Rows Removed by Filter: 803
49. 4.454 4.454 ↑ 1.0 1 2,227

Index Scan using cash_receipt_scheduled_payment_pkey on cash_receipt_scheduled_payment a_6 (cost=0.43..2.33 rows=1 width=181) (actual time=0.002..0.002 rows=1 loops=2,227)

  • Index Cond: (id = b_6.cash_receipt_scheduled_payment_id)
  • Filter: active
50. 8.828 8.828 ↑ 1.0 1 2,207

Index Scan using customer_pkey on customer cu_8 (cost=0.41..0.44 rows=1 width=174) (actual time=0.004..0.004 rows=1 loops=2,207)

  • Index Cond: ((id)::text = (a_6.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
51. 3.973 8.398 ↑ 1.0 18,877 1

Hash (cost=1,015.17..1,015.17 rows=19,517 width=43) (actual time=8.398..8.398 rows=18,877 loops=1)

  • Buckets: 32,768 Batches: 1 Memory Usage: 1,656kB
52. 4.425 4.425 ↑ 1.0 18,877 1

Seq Scan on customer_group cg_8 (cost=0.00..1,015.17 rows=19,517 width=43) (actual time=0.004..4.425 rows=18,877 loops=1)

53. 0.090 0.358 ↑ 4.3 517 1

Hash (cost=109.26..109.26 rows=2,226 width=25) (actual time=0.358..0.358 rows=517 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 62kB
54. 0.268 0.268 ↑ 4.3 517 1

Seq Scan on cash_receipt_head c_6 (cost=0.00..109.26 rows=2,226 width=25) (actual time=0.004..0.268 rows=517 loops=1)

55. 0.173 0.775 ↑ 102.0 20 1

Hash Join (cost=29.64..286.07 rows=2,039 width=2,548) (actual time=0.310..0.775 rows=20 loops=1)

  • Hash Cond: (b_7.charge_back_id = a_7.id)
56. 0.349 0.349 ↑ 1.7 3,030 1

Seq Scan on cash_receipt_line b_7 (cost=0.00..221.98 rows=5,098 width=69) (actual time=0.003..0.349 rows=3,030 loops=1)

57. 0.011 0.253 ↓ 5.0 20 1

Hash (cost=29.59..29.59 rows=4 width=1,660) (actual time=0.253..0.253 rows=20 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 12kB
58. 0.015 0.242 ↓ 5.0 20 1

Nested Loop (cost=2.38..29.59 rows=4 width=1,660) (actual time=0.030..0.242 rows=20 loops=1)

59. 0.008 0.207 ↓ 5.0 20 1

Nested Loop Left Join (cost=2.10..20.48 rows=4 width=1,672) (actual time=0.026..0.207 rows=20 loops=1)

60. 0.007 0.119 ↓ 5.0 20 1

Nested Loop (cost=1.69..18.65 rows=4 width=1,703) (actual time=0.018..0.119 rows=20 loops=1)

61. 0.009 0.012 ↓ 4.0 20 1

Bitmap Heap Scan on charge_back a_7 (cost=1.27..5.47 rows=5 width=1,640) (actual time=0.007..0.012 rows=20 loops=1)

  • Filter: (NOT deleted)
  • Heap Blocks: exact=1
62. 0.003 0.003 ↓ 4.0 20 1

Bitmap Index Scan on idx_charge_back_deleted (cost=0.00..1.27 rows=5 width=0) (actual time=0.003..0.003 rows=20 loops=1)

  • Index Cond: (deleted = false)
63. 0.100 0.100 ↑ 1.0 1 20

Index Scan using customer_pkey on customer cu_9 (cost=0.41..2.64 rows=1 width=174) (actual time=0.005..0.005 rows=1 loops=20)

  • Index Cond: ((id)::text = (a_7.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
64. 0.080 0.080 ↑ 1.0 1 20

Index Scan using customer_group_pkey on customer_group cg_9 (cost=0.41..0.46 rows=1 width=43) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: ((id)::text = (cu_9.customer_group)::text)
65. 0.020 0.020 ↑ 1.0 1 20

Index Scan using cash_receipt_head_pkey on cash_receipt_head c_7 (cost=0.28..2.28 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=20)

  • Index Cond: (id = a_7.cash_receipt_head_id)
66. 0.189 33.748 ↓ 0.0 0 1

Subquery Scan on cash_receipt_scheduled_payment_line_1 (cost=18,186.26..18,858.31 rows=1 width=4,132) (actual time=33.748..33.748 rows=0 loops=1)

  • Filter: ((cash_receipt_scheduled_payment_line_1.invoice_date <= '2020-01-08'::date) AND (cash_receipt_scheduled_payment_line_1.cash_receipt_head_id <> 'd98bf299-ad8e-4197-91b5-c04ed40fe392'::uuid) AND ((cash_receipt_scheduled_payment_line_1.line_status)::text = 'DRAFT'::text) AND ((cash_receipt_scheduled_payment_line_1.customer_id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text) AND ((cash_receipt_scheduled_payment_line_1.line_type)::text = 'SP'::text) AND ((cash_receipt_scheduled_payment_line_1.applied_amount <> '0'::numeric) OR (cash_receipt_scheduled_payment_line_1.misc_charge_amount <> '0'::numeric)))
  • Rows Removed by Filter: 2,227
67. 1.027 33.559 ↑ 2.4 2,227 1

WindowAgg (cost=18,186.26..18,713.36 rows=5,271 width=4,132) (actual time=31.060..33.559 rows=2,227 loops=1)

68. 1.340 32.532 ↑ 2.4 2,227 1

Unique (cost=18,186.26..18,594.76 rows=5,271 width=4,124) (actual time=31.054..32.532 rows=2,227 loops=1)

69. 2.343 31.192 ↑ 2.4 2,227 1

Sort (cost=18,186.26..18,199.43 rows=5,271 width=4,124) (actual time=31.053..31.192 rows=2,227 loops=1)

  • Sort Key: a_2.id, a_2.discount_amount, a_2.discount_date, a_2.due_date, a_2.invoice_id, a_2.invoice_amount, a_2.invoice_date, a_2.invoice_number, (0.00), a_2.paid_amount, a_2.purchase_order_number, a_2.scheduled_payment_status, a_2.transaction_type, a_2.customer_id, (((((cg_3.code)::text || '-'::text) || (cu_3.code)::text))::character varying(255)), cu_3.name, b_2.applied_amount, b_2.discount, b_2.service_fee, b_2.id, b_2.cash_receipt_head_id, b_2.charge_back_id, b_2.line_status, b_2.line_type, c_2.payment_number, a_2.refno_est, b_2.misc_charge_amount, b_2.gl_misc_charge_account, b_2.description, a_2.discount_taken
  • Sort Method: quicksort Memory: 1,240kB
70. 0.196 28.849 ↑ 2.4 2,227 1

Append (cost=1,397.06..12,382.81 rows=5,271 width=4,124) (actual time=8.871..28.849 rows=2,227 loops=1)

71. 0.993 27.872 ↑ 1.5 2,207 1

Hash Left Join (cost=1,397.06..12,044.02 rows=3,232 width=870) (actual time=8.871..27.872 rows=2,207 loops=1)

  • Hash Cond: (b_2.cash_receipt_head_id = c_2.id)
72. 0.922 26.510 ↑ 1.5 2,207 1

Hash Left Join (cost=1,259.98..11,874.20 rows=3,232 width=322) (actual time=8.474..26.510 rows=2,207 loops=1)

  • Hash Cond: ((cu_3.customer_group)::text = (cg_3.id)::text)
73. 2.015 17.275 ↑ 1.5 2,207 1

Nested Loop (cost=0.84..10,606.59 rows=3,232 width=353) (actual time=0.032..17.275 rows=2,207 loops=1)

74. 1.307 6.432 ↑ 1.7 2,207 1

Nested Loop (cost=0.43..8,955.14 rows=3,748 width=290) (actual time=0.018..6.432 rows=2,207 loops=1)

75. 0.671 0.671 ↑ 1.7 2,227 1

Seq Scan on cash_receipt_line b_2 (cost=0.00..221.98 rows=3,748 width=125) (actual time=0.004..0.671 rows=2,227 loops=1)

  • Filter: (NOT deleted)
  • Rows Removed by Filter: 803
76. 4.454 4.454 ↑ 1.0 1 2,227

Index Scan using cash_receipt_scheduled_payment_pkey on cash_receipt_scheduled_payment a_2 (cost=0.43..2.33 rows=1 width=181) (actual time=0.002..0.002 rows=1 loops=2,227)

  • Index Cond: (id = b_2.cash_receipt_scheduled_payment_id)
  • Filter: active
77. 8.828 8.828 ↑ 1.0 1 2,207

Index Scan using customer_pkey on customer cu_3 (cost=0.41..0.44 rows=1 width=174) (actual time=0.004..0.004 rows=1 loops=2,207)

  • Index Cond: ((id)::text = (a_2.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
78. 3.946 8.313 ↑ 1.0 18,877 1

Hash (cost=1,015.17..1,015.17 rows=19,517 width=43) (actual time=8.313..8.313 rows=18,877 loops=1)

  • Buckets: 32,768 Batches: 1 Memory Usage: 1,656kB
79. 4.367 4.367 ↑ 1.0 18,877 1

Seq Scan on customer_group cg_3 (cost=0.00..1,015.17 rows=19,517 width=43) (actual time=0.003..4.367 rows=18,877 loops=1)

80. 0.093 0.369 ↑ 4.3 517 1

Hash (cost=109.26..109.26 rows=2,226 width=25) (actual time=0.369..0.369 rows=517 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 62kB
81. 0.276 0.276 ↑ 4.3 517 1

Seq Scan on cash_receipt_head c_2 (cost=0.00..109.26 rows=2,226 width=25) (actual time=0.006..0.276 rows=517 loops=1)

82. 0.177 0.781 ↑ 102.0 20 1

Hash Join (cost=29.64..286.07 rows=2,039 width=2,548) (actual time=0.325..0.781 rows=20 loops=1)

  • Hash Cond: (b_3.charge_back_id = a_3.id)
83. 0.337 0.337 ↑ 1.7 3,030 1

Seq Scan on cash_receipt_line b_3 (cost=0.00..221.98 rows=5,098 width=69) (actual time=0.003..0.337 rows=3,030 loops=1)

84. 0.013 0.267 ↓ 5.0 20 1

Hash (cost=29.59..29.59 rows=4 width=1,660) (actual time=0.267..0.267 rows=20 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 12kB
85. 0.016 0.254 ↓ 5.0 20 1

Nested Loop (cost=2.38..29.59 rows=4 width=1,660) (actual time=0.030..0.254 rows=20 loops=1)

86. 0.014 0.218 ↓ 5.0 20 1

Nested Loop Left Join (cost=2.10..20.48 rows=4 width=1,672) (actual time=0.025..0.218 rows=20 loops=1)

87. 0.012 0.124 ↓ 5.0 20 1

Nested Loop (cost=1.69..18.65 rows=4 width=1,703) (actual time=0.017..0.124 rows=20 loops=1)

88. 0.009 0.012 ↓ 4.0 20 1

Bitmap Heap Scan on charge_back a_3 (cost=1.27..5.47 rows=5 width=1,640) (actual time=0.007..0.012 rows=20 loops=1)

  • Filter: (NOT deleted)
  • Heap Blocks: exact=1
89. 0.003 0.003 ↓ 4.0 20 1

Bitmap Index Scan on idx_charge_back_deleted (cost=0.00..1.27 rows=5 width=0) (actual time=0.003..0.003 rows=20 loops=1)

  • Index Cond: (deleted = false)
90. 0.100 0.100 ↑ 1.0 1 20

Index Scan using customer_pkey on customer cu_4 (cost=0.41..2.64 rows=1 width=174) (actual time=0.005..0.005 rows=1 loops=20)

  • Index Cond: ((id)::text = (a_3.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
91. 0.080 0.080 ↑ 1.0 1 20

Index Scan using customer_group_pkey on customer_group cg_4 (cost=0.41..0.46 rows=1 width=43) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: ((id)::text = (cu_4.customer_group)::text)
92. 0.020 0.020 ↑ 1.0 1 20

Index Scan using cash_receipt_head_pkey on cash_receipt_head c_3 (cost=0.28..2.28 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=20)

  • Index Cond: (id = a_3.cash_receipt_head_id)
93. 0.001 33.083 ↓ 0.0 0 1

WindowAgg (cost=18,768.45..18,779.39 rows=1 width=2,695) (actual time=33.083..33.083 rows=0 loops=1)

94. 0.001 33.082 ↓ 0.0 0 1

Nested Loop Left Join (cost=18,768.45..18,779.37 rows=1 width=1,660) (actual time=33.082..33.082 rows=0 loops=1)

  • Join Filter: (ch.id = cb.cash_receipt_head_id)
95. 0.001 33.081 ↓ 0.0 0 1

Nested Loop Left Join (cost=18,768.17..18,776.86 rows=1 width=1,672) (actual time=33.081..33.081 rows=0 loops=1)

96. 0.000 33.080 ↓ 0.0 0 1

Nested Loop (cost=18,767.76..18,774.23 rows=1 width=1,703) (actual time=33.080..33.080 rows=0 loops=1)

97. 0.016 33.080 ↓ 0.0 0 1

Bitmap Heap Scan on charge_back cb (cost=18,767.34..18,771.59 rows=1 width=1,640) (actual time=33.080..33.080 rows=0 loops=1)

  • Filter: ((NOT deleted) AND (open_balance <> '0'::numeric) AND (NOT (hashed SubPlan 1)) AND ((customer_id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text) AND (cash_receipt_head_id = 'd98bf299-ad8e-4197-91b5-c04ed40fe392'::uuid))
  • Rows Removed by Filter: 20
  • Heap Blocks: exact=1
98. 0.003 0.003 ↓ 4.0 20 1

Bitmap Index Scan on idx_charge_back_deleted (cost=0.00..1.27 rows=5 width=0) (actual time=0.003..0.003 rows=20 loops=1)

  • Index Cond: (deleted = false)
99.          

SubPlan (for Bitmap Heap Scan)

100. 0.129 33.061 ↓ 0.0 0 1

Subquery Scan on cash_receipt_scheduled_payment_line_2 (cost=18,186.26..18,766.07 rows=1 width=16) (actual time=33.061..33.061 rows=0 loops=1)

  • Filter: (((cash_receipt_scheduled_payment_line_2.line_status)::text = 'DRAFT'::text) AND (cash_receipt_scheduled_payment_line_2.cash_receipt_head_id = 'd98bf299-ad8e-4197-91b5-c04ed40fe392'::uuid) AND ((cash_receipt_scheduled_payment_line_2.line_type)::text = 'CB'::text) AND ((cash_receipt_scheduled_payment_line_2.applied_amount <> '0'::numeric) OR (cash_receipt_scheduled_payment_line_2.misc_charge_amount <> '0'::numeric)))
  • Rows Removed by Filter: 2,227
101. 0.714 32.932 ↑ 2.4 2,227 1

Subquery Scan on v (cost=18,186.26..18,647.47 rows=5,271 width=4,132) (actual time=31.066..32.932 rows=2,227 loops=1)

102. 1.023 32.218 ↑ 2.4 2,227 1

Unique (cost=18,186.26..18,594.76 rows=5,271 width=4,124) (actual time=31.064..32.218 rows=2,227 loops=1)

103. 2.371 31.195 ↑ 2.4 2,227 1

Sort (cost=18,186.26..18,199.43 rows=5,271 width=4,124) (actual time=31.063..31.195 rows=2,227 loops=1)

  • Sort Key: a_4.id, a_4.discount_amount, a_4.discount_date, a_4.due_date, a_4.invoice_id, a_4.invoice_amount, a_4.invoice_date, a_4.invoice_number, (0.00), a_4.paid_amount, a_4.purchase_order_number, a_4.scheduled_payment_status, a_4.transaction_type, a_4.customer_id, (((((cg_6.code)::text || '-'::text) || (cu_6.code)::text))::character varying(255)), cu_6.name, b_4.applied_amount, b_4.discount, b_4.service_fee, b_4.id, b_4.cash_receipt_head_id, b_4.charge_back_id, b_4.line_status, b_4.line_type, c_4.payment_number, a_4.refno_est, b_4.misc_charge_amount, b_4.gl_misc_charge_account, b_4.description, a_4.discount_taken
  • Sort Method: quicksort Memory: 1,240kB
104. 0.208 28.824 ↑ 2.4 2,227 1

Append (cost=1,397.06..12,382.81 rows=5,271 width=4,124) (actual time=8.749..28.824 rows=2,227 loops=1)

105. 0.966 27.811 ↑ 1.5 2,207 1

Hash Left Join (cost=1,397.06..12,044.02 rows=3,232 width=870) (actual time=8.748..27.811 rows=2,207 loops=1)

  • Hash Cond: (b_4.cash_receipt_head_id = c_4.id)
106. 0.917 26.484 ↑ 1.5 2,207 1

Hash Left Join (cost=1,259.98..11,874.20 rows=3,232 width=322) (actual time=8.361..26.484 rows=2,207 loops=1)

  • Hash Cond: ((cu_6.customer_group)::text = (cg_6.id)::text)
107. 2.028 17.386 ↑ 1.5 2,207 1

Nested Loop (cost=0.84..10,606.59 rows=3,232 width=353) (actual time=0.044..17.386 rows=2,207 loops=1)

108. 1.413 6.530 ↑ 1.7 2,207 1

Nested Loop (cost=0.43..8,955.14 rows=3,748 width=290) (actual time=0.018..6.530 rows=2,207 loops=1)

109. 0.663 0.663 ↑ 1.7 2,227 1

Seq Scan on cash_receipt_line b_4 (cost=0.00..221.98 rows=3,748 width=125) (actual time=0.004..0.663 rows=2,227 loops=1)

  • Filter: (NOT deleted)
  • Rows Removed by Filter: 803
110. 4.454 4.454 ↑ 1.0 1 2,227

Index Scan using cash_receipt_scheduled_payment_pkey on cash_receipt_scheduled_payment a_4 (cost=0.43..2.33 rows=1 width=181) (actual time=0.002..0.002 rows=1 loops=2,227)

  • Index Cond: (id = b_4.cash_receipt_scheduled_payment_id)
  • Filter: active
111. 8.828 8.828 ↑ 1.0 1 2,207

Index Scan using customer_pkey on customer cu_6 (cost=0.41..0.44 rows=1 width=174) (actual time=0.004..0.004 rows=1 loops=2,207)

  • Index Cond: ((id)::text = (a_4.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
112. 3.870 8.181 ↑ 1.0 18,877 1

Hash (cost=1,015.17..1,015.17 rows=19,517 width=43) (actual time=8.181..8.181 rows=18,877 loops=1)

  • Buckets: 32,768 Batches: 1 Memory Usage: 1,656kB
113. 4.311 4.311 ↑ 1.0 18,877 1

Seq Scan on customer_group cg_6 (cost=0.00..1,015.17 rows=19,517 width=43) (actual time=0.004..4.311 rows=18,877 loops=1)

114. 0.096 0.361 ↑ 4.3 517 1

Hash (cost=109.26..109.26 rows=2,226 width=25) (actual time=0.361..0.361 rows=517 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 62kB
115. 0.265 0.265 ↑ 4.3 517 1

Seq Scan on cash_receipt_head c_4 (cost=0.00..109.26 rows=2,226 width=25) (actual time=0.004..0.265 rows=517 loops=1)

116. 0.178 0.805 ↑ 102.0 20 1

Hash Join (cost=29.64..286.07 rows=2,039 width=2,548) (actual time=0.337..0.805 rows=20 loops=1)

  • Hash Cond: (b_5.charge_back_id = a_5.id)
117. 0.353 0.353 ↑ 1.7 3,030 1

Seq Scan on cash_receipt_line b_5 (cost=0.00..221.98 rows=5,098 width=69) (actual time=0.004..0.353 rows=3,030 loops=1)

118. 0.013 0.274 ↓ 5.0 20 1

Hash (cost=29.59..29.59 rows=4 width=1,660) (actual time=0.274..0.274 rows=20 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 12kB
119. 0.022 0.261 ↓ 5.0 20 1

Nested Loop (cost=2.38..29.59 rows=4 width=1,660) (actual time=0.030..0.261 rows=20 loops=1)

120. 0.018 0.219 ↓ 5.0 20 1

Nested Loop Left Join (cost=2.10..20.48 rows=4 width=1,672) (actual time=0.025..0.219 rows=20 loops=1)

121. 0.009 0.121 ↓ 5.0 20 1

Nested Loop (cost=1.69..18.65 rows=4 width=1,703) (actual time=0.017..0.121 rows=20 loops=1)

122. 0.009 0.012 ↓ 4.0 20 1

Bitmap Heap Scan on charge_back a_5 (cost=1.27..5.47 rows=5 width=1,640) (actual time=0.007..0.012 rows=20 loops=1)

  • Filter: (NOT deleted)
  • Heap Blocks: exact=1
123. 0.003 0.003 ↓ 4.0 20 1

Bitmap Index Scan on idx_charge_back_deleted (cost=0.00..1.27 rows=5 width=0) (actual time=0.003..0.003 rows=20 loops=1)

  • Index Cond: (deleted = false)
124. 0.100 0.100 ↑ 1.0 1 20

Index Scan using customer_pkey on customer cu_7 (cost=0.41..2.64 rows=1 width=174) (actual time=0.005..0.005 rows=1 loops=20)

  • Index Cond: ((id)::text = (a_5.customer_id)::text)
  • Filter: (ar_location = 'T'::bpchar)
125. 0.080 0.080 ↑ 1.0 1 20

Index Scan using customer_group_pkey on customer_group cg_7 (cost=0.41..0.46 rows=1 width=43) (actual time=0.004..0.004 rows=1 loops=20)

  • Index Cond: ((id)::text = (cu_7.customer_group)::text)
126. 0.020 0.020 ↑ 1.0 1 20

Index Scan using cash_receipt_head_pkey on cash_receipt_head c_5 (cost=0.28..2.28 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=20)

  • Index Cond: (id = a_5.cash_receipt_head_id)
127. 0.000 0.000 ↓ 0.0 0

Index Scan using customer_pkey on customer cu_5 (cost=0.41..2.64 rows=1 width=174) (never executed)

  • Index Cond: ((id)::text = '92e70357-4df3-4a52-9bac-adbc5b49e087'::text)
  • Filter: (ar_location = 'T'::bpchar)
128. 0.000 0.000 ↓ 0.0 0

Index Scan using customer_group_pkey on customer_group cg_5 (cost=0.41..2.63 rows=1 width=43) (never executed)

  • Index Cond: ((id)::text = (cu_5.customer_group)::text)
129. 0.000 0.000 ↓ 0.0 0

Index Scan using cash_receipt_head_pkey on cash_receipt_head ch (cost=0.28..2.50 rows=1 width=20) (never executed)

  • Index Cond: (id = 'd98bf299-ad8e-4197-91b5-c04ed40fe392'::uuid)