QUERY PLAN
Aggregate (cost=615.24..615.25 rows=1 width=200)
-> Unique (cost=614.58..614.89 rows=6 width=119)
-> Sort (cost=614.58..614.59 rows=6 width=119)
Sort Key: (CASE WHEN (r.status = 2) THEN 1 ELSE 0 END) DESC, r.id, r.status, r.amount, r.occurrence_at, r.settle_accounts_at, r.settle_accounts_by, r.description, r.created_by, r.created_at, r.updated_at, r.refuse_description, r.client_id, 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
-> Group (cost=614.46..614.50 rows=6 width=119)
Group Key: r.id
-> Sort (cost=614.46..614.47 rows=6 width=115)
Sort Key: r.id
-> Nested Loop Left Join (cost=152.33..614.38 rows=6 width=115)
-> Nested Loop Left Join (cost=152.04..610.37 rows=6 width=115)
-> Nested Loop (cost=151.75..606.52 rows=6 width=115)
-> Hash Join (cost=151.46..603.61 rows=6 width=8)
Hash Cond: (rvr.reimbursement_id = rsr.reimbursement_id)
-> Seq Scan on tbl_reimbursement_verify_rels rvr (cost=0.00..410.29 rows=8359 width=4)
Filter: (user_id = 1001)
-> Hash (cost=151.39..151.39 rows=6 width=4)
-> Seq Scan on tbl_reimbursement_settle_rels rsr (cost=0.00..151.39 rows=6 width=4)
Filter: (user_id = 1001)
-> Index Scan using tbl_reimbursements_pkey on tbl_reimbursements r (cost=0.29..0.49 rows=1 width=115)
Index Cond: (id = rvr.reimbursement_id)
Filter: (status <> 0)
-> Index Only Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..0.63 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..0.66 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 18))
Filter: (object_type = 7)