QUERY PLAN
Limit (cost=242.98..242.98 rows=1 width=479)
-> Sort (cost=242.98..242.98 rows=1 width=479)
Sort Key: (CASE WHEN (r.status = 1) THEN 0 ELSE 1 END), (CASE WHEN (r.status = 1) THEN r.created_at ELSE r.verify_at END) DESC, r.created_at DESC
-> Group (cost=234.90..242.97 rows=1 width=479)
Group Key: r.id
-> Nested Loop Left Join (cost=234.90..242.96 rows=1 width=467)
-> Merge Left Join (cost=234.61..234.64 rows=1 width=467)
Merge Cond: (r.id = rcvr.approve_id)
-> Sort (cost=233.58..233.59 rows=1 width=467)
Sort Key: r.id
-> Hash Right Join (cost=172.65..233.57 rows=1 width=467)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..53.03 rows=3003 width=4)
-> Hash (cost=172.63..172.63 rows=1 width=467)
-> Seq Scan on tbl_approves r (cost=0.00..172.63 rows=1 width=467)
Filter: ((created_by = 1001) AND (status = 0))
-> Sort (cost=1.03..1.03 rows=2 width=4)
Sort Key: rcvr.approve_id
-> Seq Scan on tbl_approve_cancel_verify_rels rcvr (cost=0.00..1.02 rows=2 width=4)
-> 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))