QUERY PLAN
GroupAggregate (cost=15.61..15.68 rows=2 width=85)
Group Key: t.id, e.id, b.serial_no
-> Sort (cost=15.61..15.61 rows=2 width=69)
Sort Key: b.serial_no
-> Hash Left Join (cost=1.39..15.60 rows=2 width=69)
Hash Cond: (e.erp_bank_id = b.id)
-> Nested Loop Left Join (cost=0.14..14.35 rows=2 width=63)
-> Nested Loop Left Join (cost=0.00..11.22 rows=2 width=59)
Join Filter: (a.erp_wage_ticket_id = t.id)
-> Nested Loop (cost=0.00..2.62 rows=1 width=55)
-> Seq Scan on tbl_erp_wage_ticket_bank_outs e (cost=0.00..1.39 rows=1 width=28)
Filter: ((settle_at IS NOT NULL) AND (amount > '0'::numeric) AND (erp_wage_ticket_id = 9) AND (id = 21))
-> Seq Scan on tbl_erp_wage_tickets t (cost=0.00..1.23 rows=1 width=31)
Filter: ((status = ANY ('{2,5}'::integer[])) AND (id = 9))
-> Seq Scan on tbl_erp_wage_ticket_amounts a (cost=0.00..8.31 rows=23 width=8)
Filter: (erp_wage_ticket_id = 9)
-> Index Scan using tbl_users_pkey on tbl_users u (cost=0.14..1.55 rows=1 width=8)
Index Cond: (id = a.user_id)
-> Hash (cost=1.11..1.11 rows=11 width=10)
-> Seq Scan on tbl_erp_banks b (cost=0.00..1.11 rows=11 width=10)