QUERY PLAN
Limit (cost=293.37..293.39 rows=10 width=448)
-> Sort (cost=293.37..293.39 rows=10 width=448)
Sort Key: (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 1001)) THEN 1 WHEN ((rcvr.status = 0) AND (r.next_cancel_verify_user = 1001)) THEN 2 ELSE 0 END) DESC, (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=292.98..293.20 rows=10 width=448)
Group Key: r.id, (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 1001)) THEN 1 WHEN ((rcvr.status = 0) AND (r.next_cancel_verify_user = 1001)) THEN 2 ELSE 0 END)
-> Sort (cost=292.98..293.00 rows=10 width=436)
Sort Key: r.id, (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 1001)) THEN 1 WHEN ((rcvr.status = 0) AND (r.next_cancel_verify_user = 1001)) THEN 2 ELSE 0 END) DESC
-> Nested Loop Left Join (cost=157.31..292.81 rows=10 width=436)
-> Hash Join (cost=157.02..209.51 rows=10 width=440)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..47.11 rows=1407 width=8)
Filter: (user_id = 1001)
-> Hash (cost=156.83..156.83 rows=15 width=436)
-> Hash Right Join (cost=134.59..156.83 rows=15 width=436)
Hash Cond: (rcvr.approve_id = r.id)
-> Seq Scan on tbl_approve_cancel_verify_rels rcvr (cost=0.00..19.70 rows=970 width=8)
-> Hash (cost=134.40..134.40 rows=15 width=432)
-> Seq Scan on tbl_approves r (cost=0.00..134.40 rows=15 width=432)
Filter: ((status <> 0) AND (status = ANY ('{1,5}'::integer[])))
-> 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))