QUERY PLAN
Limit (cost=110.31..110.33 rows=8 width=406)
-> Sort (cost=110.31..110.33 rows=8 width=406)
Sort Key: (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 1000)) THEN 1 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=110.05..110.19 rows=8 width=406)
Group Key: r.id, (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 1000)) THEN 1 ELSE 0 END)
-> Sort (cost=110.05..110.07 rows=8 width=394)
Sort Key: r.id, (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 1000)) THEN 1 ELSE 0 END) DESC
-> Nested Loop Left Join (cost=0.57..109.93 rows=8 width=394)
-> Nested Loop (cost=0.28..95.85 rows=8 width=394)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..37.46 rows=8 width=8)
Filter: (user_id = 1000)
-> Index Scan using tbl_approves_pkey on tbl_approves r (cost=0.28..7.30 rows=1 width=390)
Index Cond: (id = rvr.approve_id)
Filter: (status <> 0)
-> Index Only Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..1.75 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 17))