QUERY PLAN
Aggregate (cost=1246.75..1246.76 rows=1 width=32)
-> Unique (cost=1233.31..1242.13 rows=168 width=390)
-> Sort (cost=1233.31..1233.73 rows=168 width=390)
Sort Key: r.id, r.client_id, r.project_id, r.title, r.status, r.next_verify_user, r.verify_at, r.description, r.refuse_description, r.is_resubmited, r.created_at, r.updated_at, r.supplier_id, r.purchase_contract_id, r.amount, r.borrow_amount, r.borrow_collect_day, r.borrow_collect_status, r.borrow_collect_description, r.borrow_collect_at
-> Group (cost=1226.26..1227.10 rows=168 width=390)
Group Key: r.id
-> Sort (cost=1226.26..1226.68 rows=168 width=390)
Sort Key: r.id
-> Nested Loop Left Join (cost=148.60..1220.05 rows=168 width=390)
-> Nested Loop (cost=148.31..274.91 rows=168 width=390)
-> Seq Scan on tbl_users u (cost=0.00..8.09 rows=1 width=4)
Filter: ((id = 5300) AND (department_id = 1))
-> Hash Right Join (cost=148.31..265.14 rows=168 width=390)
Hash Cond: (rccr.approve_id = r.id)
Filter: ((r.created_by = ANY ('{5311,5300}'::integer[])) OR (rccr.user_id = 5300) OR (rvr.user_id = 5300))
-> Seq Scan on tbl_approve_carbon_copy_rels rccr (cost=0.00..80.97 rows=5197 width=8)
-> Hash (cost=144.49..144.49 rows=305 width=394)
-> Hash Right Join (cost=108.05..144.49 rows=305 width=394)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..31.77 rows=1777 width=8)
-> Hash (cost=104.41..104.41 rows=291 width=390)
-> Seq Scan on tbl_approves r (cost=0.00..104.41 rows=291 width=390)
Filter: ((status <> 0) AND (created_by = 5300))
-> Index Only Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..5.62 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 17))