QUERY PLAN
GroupAggregate (cost=26.30..26.34 rows=1 width=111)
Group Key: s.id, t.id, p.bank_settle_at
-> Sort (cost=26.30..26.30 rows=1 width=81)
Sort Key: p.bank_settle_at
-> Nested Loop Left Join (cost=16.81..26.29 rows=1 width=81)
-> Nested Loop (cost=16.68..26.08 rows=1 width=75)
-> Hash Right Join (cost=16.68..23.51 rows=1 width=26)
Hash Cond: (bo.erp_payment_ticket_id = p.id)
-> Seq Scan on tbl_erp_payment_ticket_bank_outs bo (cost=0.00..5.78 rows=278 width=8)
-> Hash (cost=16.66..16.66 rows=1 width=26)
-> Nested Loop (cost=0.56..16.66 rows=1 width=26)
-> Index Scan using tbl_erp_payment_ticket_settles_pkey on tbl_erp_payment_ticket_settles s (cost=0.28..8.30 rows=1 width=18)
Index Cond: (id = 2396)
Filter: ((amount > '0'::numeric) AND (erp_other_payment_ticket_id = 46))
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets p (cost=0.28..8.30 rows=1 width=12)
Index Cond: (id = s.erp_payment_ticket_id)
Filter: (is_payment_settle AND (bank_settle_at IS NOT NULL) AND (status = ANY ('{2,5}'::integer[])))
-> Seq Scan on tbl_erp_other_payment_tickets t (cost=0.00..2.56 rows=1 width=53)
Filter: (id = 46)
-> Index Scan using tbl_erp_banks_pkey on tbl_erp_banks b (cost=0.14..0.20 rows=1 width=10)
Index Cond: (id = bo.erp_bank_id)