QUERY PLAN
Aggregate (cost=161.94..161.95 rows=1 width=8)
-> Sort (cost=161.82..161.84 rows=8 width=273)
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=161.62..161.70 rows=8 width=273)
Group Key: r.id
-> Sort (cost=161.62..161.64 rows=8 width=22)
Sort Key: r.id
-> Nested Loop Left Join (cost=94.67..161.50 rows=8 width=22)
-> Nested Loop (cost=94.38..147.46 rows=8 width=22)
-> Hash Join (cost=94.10..143.34 rows=7 width=8)
Hash Cond: (rvr.approve_id = rccr.approve_id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..37.46 rows=1171 width=4)
Filter: (user_id = 1001)
-> Hash (cost=93.96..93.96 rows=11 width=4)
-> Seq Scan on tbl_approve_carbon_copy_rels rccr (cost=0.00..93.96 rows=11 width=4)
Filter: (user_id = 1000)
-> Index Scan using tbl_approves_pkey on tbl_approves r (cost=0.28..0.59 rows=1 width=30)
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))