QUERY PLAN
Aggregate (cost=65.98..65.99 rows=1 width=8)
-> Group (cost=65.94..65.96 rows=1 width=469)
Group Key: r.id, (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 5495)) THEN 1 WHEN ((rcvr.status = 0) AND (r.next_cancel_verify_user = 5495)) THEN 2 ELSE 0 END)
-> Sort (cost=65.94..65.95 rows=1 width=8)
Sort Key: r.id, (CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 5495)) THEN 1 WHEN ((rcvr.status = 0) AND (r.next_cancel_verify_user = 5495)) THEN 2 ELSE 0 END)
-> Nested Loop Left Join (cost=35.55..65.93 rows=1 width=8)
-> Hash Join (cost=35.40..57.74 rows=1 width=20)
Hash Cond: (r.id = rvr.approve_id)
Join Filter: (((r.next_verify_user = 5495) AND (rvr.status = 0)) OR ((r.next_cancel_verify_user = 5495) AND (rcvr.status = 0)))
-> Hash Right Join (cost=13.21..35.51 rows=6 width=16)
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=13.20..13.20 rows=1 width=20)
-> Seq Scan on tbl_approves r (cost=0.00..13.20 rows=1 width=20)
Filter: ((status <> 0) AND (status = ANY ('{1,5}'::integer[])) AND ((next_verify_user = 5495) OR (next_cancel_verify_user = 5495)))
-> Hash (cost=22.12..22.12 rows=5 width=8)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..22.12 rows=5 width=8)
Filter: (user_id = 5495)
-> Index Only Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.15..8.17 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 17))