QUERY PLAN
Aggregate (cost=1750.28..1750.29 rows=1 width=32)
-> Merge Join (cost=1748.69..1750.27 rows=1 width=64)
Merge Cond: (tbl_erp_cash_cost_tickets.reimbursement_id = r.id)
-> Sort (cost=12.86..12.87 rows=1 width=68)
Sort Key: tbl_erp_cash_cost_tickets.reimbursement_id
-> Seq Scan on tbl_erp_cash_cost_tickets (cost=0.00..12.85 rows=1 width=68)
Filter: ((settle_amount < amount) AND (status = 2))
-> Unique (cost=1735.83..1736.58 rows=65 width=4)
-> Group (cost=1735.83..1736.42 rows=65 width=4)
Group Key: r.id
-> Sort (cost=1735.83..1736.13 rows=117 width=4)
Sort Key: r.id
-> Hash Left Join (cost=1350.41..1731.81 rows=117 width=4)
Hash Cond: (r.id = rccr.reimbursement_id)
Filter: ((r.created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1017,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5300,5311,5332,5360,5388,5446,5449}'::integer[])) OR (rccr.user_id = 5250) OR (rsr.user_id = 5250) OR (rvr.user_id = 5250))
-> Hash Right Join (cost=1338.25..1717.95 rows=169 width=16)
Hash Cond: (rvr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_verify_rels rvr (cost=0.00..305.46 rows=19346 width=8)
-> Hash (cost=1337.44..1337.44 rows=65 width=12)
-> Nested Loop Left Join (cost=241.13..1337.44 rows=65 width=12)
-> Nested Loop Left Join (cost=240.84..856.48 rows=65 width=12)
-> Hash Right Join (cost=240.55..375.68 rows=65 width=12)
Hash Cond: (rsr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_settle_rels rsr (cost=0.00..115.55 rows=7455 width=8)
-> Hash (cost=239.74..239.74 rows=65 width=12)
-> Seq Scan on tbl_reimbursements r (cost=0.00..239.74 rows=65 width=12)
Filter: ((status <> 0) AND (status = 2))
-> Index Only Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..7.39 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 15))
-> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt2 (cost=0.29..7.39 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 18))
Filter: (object_type = 7)
-> Hash (cost=7.07..7.07 rows=407 width=8)
-> Seq Scan on tbl_reimbursement_carbon_copy_rels rccr (cost=0.00..7.07 rows=407 width=8)