QUERY PLAN
Aggregate (cost=1555.64..1555.65 rows=1 width=8)
-> Unique (cost=1554.02..1555.32 rows=26 width=119)
-> Sort (cost=1554.02..1554.08 rows=26 width=119)
Sort Key: r.created_at DESC, r.id, r.status, r.amount, r.occurrence_at, r.settle_accounts_at, r.settle_accounts_by, r.description, r.created_by, r.updated_at, r.refuse_description, r.project_id, r.next_verify_user, r.is_resubmited, r.work_log_id, r.pre_sales_id, r.implement_record_id, r.have_invoice, (CASE WHEN (r.status = 2) THEN 1 ELSE 0 END)
-> Group (cost=1553.21..1553.41 rows=26 width=119)
Group Key: r.id
-> Sort (cost=1553.21..1553.28 rows=26 width=115)
Sort Key: r.id
-> Nested Loop Left Join (cost=617.20..1552.60 rows=26 width=115)
-> Nested Loop Left Join (cost=616.91..1265.12 rows=26 width=115)
-> Hash Left Join (cost=616.62..1056.23 rows=26 width=115)
Hash Cond: (r.id = rccr.reimbursement_id)
Filter: ((r.created_by = ANY ('{1015,1015,1023,1022,5248,5085}'::integer[])) OR (rccr.user_id = 1015) OR (rsr.user_id = 1015) OR (rvr.user_id = 1015))
-> Hash Right Join (cost=603.63..1042.58 rows=74 width=123)
Hash Cond: (rvr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_verify_rels rvr (cost=0.00..354.43 rows=22343 width=8)
-> Hash (cost=603.28..603.28 rows=28 width=119)
-> Hash Right Join (cost=450.82..603.28 rows=28 width=119)
Hash Cond: (rsr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_settle_rels rsr (cost=0.00..130.31 rows=8431 width=8)
-> Hash (cost=450.47..450.47 rows=28 width=115)
-> Seq Scan on tbl_reimbursements r (cost=0.00..450.47 rows=28 width=115)
Filter: ((client_id = 2128) AND ((status <> 0) OR (created_by = 1015)))
-> Hash (cost=7.44..7.44 rows=444 width=8)
-> Seq Scan on tbl_reimbursement_carbon_copy_rels rccr (cost=0.00..7.44 rows=444 width=8)
-> Index Only Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..8.02 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..11.05 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 18))
Filter: (object_type = 7)