QUERY PLAN
Limit (cost=194.75..194.85 rows=2 width=171)
-> Unique (cost=194.75..194.85 rows=2 width=171)
-> Sort (cost=194.75..194.76 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.client_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=176.65..194.74 rows=2 width=171)
Group Key: r.id
-> Nested Loop Left Join (cost=176.65..194.73 rows=5 width=167)
Join Filter: (dt2.object_id = r.id)
-> Merge Left Join (cost=176.65..176.70 rows=5 width=167)
Merge Cond: (r.id = dt1.object_id)
-> Sort (cost=160.00..160.01 rows=5 width=167)
Sort Key: r.id
-> Hash Left Join (cost=97.44..159.94 rows=5 width=167)
Hash Cond: (r.id = rvr.reimbursement_id)
Filter: ((r.created_by = ANY ('{5493,5495}'::integer[])) OR (rccr.user_id = 5495) OR (rsr.user_id = 5495) OR (rvr.user_id = 5495))
-> Hash Right Join (cost=52.11..100.86 rows=50 width=175)
Hash Cond: (rccr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_carbon_copy_rels rccr (cost=0.00..30.40 rows=2040 width=8)
-> Hash (cost=51.99..51.99 rows=10 width=171)
-> Hash Right Join (cost=16.17..51.99 rows=10 width=171)
Hash Cond: (rsr.reimbursement_id = r.id)
-> Seq Scan on tbl_reimbursement_settle_rels rsr (cost=0.00..30.40 rows=2040 width=8)
-> 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 (project_id = 1))
-> Hash (cost=25.70..25.70 rows=1570 width=8)
-> Seq Scan on tbl_reimbursement_verify_rels rvr (cost=0.00..25.70 rows=1570 width=8)
-> 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))