Limit (cost=660.44..2020.49 rows=20 width=181) |
-> Result (cost=660.44..5828.63 rows=76 width=181) |
-> Sort (cost=660.44..660.63 rows=76 width=83) |
Sort Key: sc.signed_at DESC, sc.created_at DESC |
-> Nested Loop (cost=507.75..658.41 rows=76 width=83) |
-> Hash Left Join (cost=507.47..521.20 rows=76 width=39) |
Hash Cond: (sc_1.id = p.id) |
Filter: (((scpcrd.remind_date >= '2025-08-01'::date) AND (scpcrd.remind_date <= '2025-08-31'::date)) OR ((CASE WHEN (p.collected IS NULL) THEN '0'::numeric ELSE p.collected END < (SubPlan 6)) AND (CASE WHEN (scpcrd.remind_date <= '2025-08-09'::date) THEN ((SubPlan 7) - CASE WHEN (p.collected IS NULL) THEN '0'::numeric ELSE p.collected END) ELSE '0'::numeric END > '0'::numeric))) |
-> Hash Left Join (cost=231.16..243.38 rows=572 width=37) |
Hash Cond: (scpcrd.contract_id = sc_1.id) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrd (cost=0.00..10.72 rows=572 width=33) |
-> Hash (cost=206.07..206.07 rows=2007 width=8) |
-> Seq Scan on tbl_purchase_contracts sc_1 (cost=0.00..206.07 rows=2007 width=8) |
-> Hash (cost=251.23..251.23 rows=2007 width=10) |
-> Subquery Scan on p (cost=211.09..251.23 rows=2007 width=10) |
-> HashAggregate (cost=211.09..231.16 rows=2007 width=10) |
Group Key: spc.id |
-> Seq Scan on tbl_purchase_contracts spc (cost=0.00..206.07 rows=2007 width=10) |
SubPlan 6 |
-> Aggregate (cost=13.58..13.59 rows=1 width=32) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrdsub_5 (cost=0.00..13.58 rows=1 width=6) |
Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |
SubPlan 7 |
-> Aggregate (cost=13.58..13.59 rows=1 width=32) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrdsub_6 (cost=0.00..13.58 rows=1 width=6) |
Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |
-> Index Scan using tbl_purchase_contracts_pkey on tbl_purchase_contracts sc (cost=0.28..1.81 rows=1 width=16) |
Index Cond: (id = scpcrd.contract_id) |
Filter: ((NOT is_draft) AND (NOT is_refuse)) |
SubPlan 1 |
-> Aggregate (cost=13.58..13.59 rows=1 width=32) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrdsub (cost=0.00..13.58 rows=1 width=6) |
Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |
SubPlan 2 |
-> Aggregate (cost=13.58..13.59 rows=1 width=32) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrdsub_1 (cost=0.00..13.58 rows=1 width=6) |
Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |
SubPlan 3 |
-> Aggregate (cost=13.58..13.59 rows=1 width=32) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrdsub_2 (cost=0.00..13.58 rows=1 width=6) |
Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |
SubPlan 4 |
-> Aggregate (cost=13.58..13.59 rows=1 width=32) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrdsub_3 (cost=0.00..13.58 rows=1 width=6) |
Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |
SubPlan 5 |
-> Aggregate (cost=13.58..13.59 rows=1 width=32) |
-> Seq Scan on tbl_purchase_contract_payment_collection_remind_dates scpcrdsub_4 (cost=0.00..13.58 rows=1 width=6) |
Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |