QUERY PLAN
Aggregate (cost=268.21..268.22 rows=1 width=8)
-> Sort (cost=268.19..268.20 rows=1 width=477)
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=260.12..268.18 rows=1 width=477)
Group Key: r.id
-> Nested Loop Left Join (cost=260.12..268.18 rows=1 width=22)
-> Merge Left Join (cost=259.83..259.86 rows=1 width=22)
Merge Cond: (r.id = rcvr.approve_id)
-> Sort (cost=258.80..258.80 rows=1 width=22)
Sort Key: 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=4)
-> Hash (cost=196.59..196.59 rows=1 width=30)
-> Seq Scan on tbl_approves r (cost=0.00..196.59 rows=1 width=30)
Filter: ((created_by = 1000) 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))