QUERY PLAN
Aggregate (cost=128.97..128.98 rows=1 width=8)
-> Unique (cost=128.85..128.94 rows=2 width=171)
-> Sort (cost=128.85..128.85 rows=2 width=171)
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, (CASE WHEN (r.status = 2) THEN 1 ELSE 0 END)
-> Group (cost=109.95..128.84 rows=2 width=171)
Group Key: r.id
-> Nested Loop Left Join (cost=109.95..128.73 rows=40 width=167)
Join Filter: (dt2.object_id = r.id)
-> Merge Left Join (cost=109.95..110.18 rows=40 width=167)
Merge Cond: (r.id = dt1.object_id)
-> Sort (cost=93.31..93.41 rows=40 width=167)
Sort Key: r.id
-> Hash Right Join (cost=46.14..92.24 rows=40 width=167)
Hash Cond: (rsr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_settle_rels rsr (cost=0.00..30.40 rows=2040 width=4)
-> Hash (cost=46.04..46.04 rows=8 width=167)
-> Hash Right Join (cost=16.17..46.04 rows=8 width=167)
Hash Cond: (rvr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_verify_rels rvr (cost=0.00..25.70 rows=1570 width=4)
-> Hash (cost=16.15..16.15 rows=2 width=167)
-> Seq Scan on tbl_reimbursements r (cost=0.00..16.15 rows=2 width=167)
Filter: ((status <> 0) AND (client_id = 1))
-> Sort (cost=16.65..16.66 rows=3 width=4)
Sort Key: dt1.object_id
-> Seq Scan on tbl_term_taxonomy_relationships dt1 (cost=0.00..16.62 rows=3 width=4)
Filter: (term_id = 15)
-> Materialize (cost=0.00..17.95 rows=1 width=4)
-> Seq Scan on tbl_term_taxonomy_relationships dt2 (cost=0.00..17.95 rows=1 width=4)
Filter: ((term_id = 18) AND (object_type = 7))