QUERY PLAN
Aggregate (cost=416.71..416.72 rows=1 width=8)
-> Sort (cost=416.70..416.70 rows=1 width=465)
Sort Key: r.status, r.created_at DESC
-> Group (cost=416.68..416.69 rows=1 width=465)
Group Key: r.id
-> Sort (cost=416.68..416.68 rows=2 width=14)
Sort Key: r.id
-> Hash Right Join (cost=268.17..416.67 rows=2 width=14)
Hash Cond: (rccr.approve_id = r.id)
Filter: ((r.created_by = 1013) OR (rccr.user_id = 1013) OR (rvr.user_id = 1013) OR (rcvr.user_id = 1013))
-> Seq Scan on tbl_approve_carbon_copy_rels rccr (cost=0.00..119.41 rows=7741 width=8)
-> Hash (cost=268.15..268.15 rows=1 width=26)
-> Nested Loop Left Join (cost=196.89..268.15 rows=1 width=26)
-> Nested Loop Left Join (cost=196.60..259.83 rows=1 width=26)
Join Filter: (rcvr.approve_id = r.id)
-> Hash Right Join (cost=196.60..258.79 rows=1 width=22)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..54.03 rows=3103 width=8)
-> Hash (cost=196.59..196.59 rows=1 width=22)
-> Seq Scan on tbl_approves r (cost=0.00..196.59 rows=1 width=22)
Filter: ((status <> 0) AND (purchase_contract_id = 4499))
-> Seq Scan on tbl_approve_cancel_verify_rels rcvr (cost=0.00..1.02 rows=2 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.31 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 17))