QUERY PLAN
Limit (cost=1471.87..1471.92 rows=20 width=402)
-> Sort (cost=1471.87..1474.77 rows=1161 width=402)
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
-> HashAggregate (cost=1423.56..1440.98 rows=1161 width=402)
Group Key: r.id
-> Hash Right Join (cost=389.67..1420.66 rows=1161 width=390)
Hash Cond: (dt1.object_id = r.id)
-> Seq Scan on tbl_term_taxonomy_relationships dt1 (cost=0.00..1022.28 rows=1624 width=4)
Filter: (term_id = 17)
-> Hash (cost=375.16..375.16 rows=1161 width=390)
-> Hash Right Join (cost=179.78..375.16 rows=1161 width=390)
Hash Cond: (rccr.approve_id = r.id)
Filter: ((r.created_by = 5295) OR (rccr.user_id = 5295) OR (rvr.user_id = 5295))
-> Seq Scan on tbl_approve_carbon_copy_rels rccr (cost=0.00..80.97 rows=5197 width=8)
-> Hash (cost=157.68..157.68 rows=1768 width=394)
-> Hash Right Join (cost=121.24..157.68 rows=1768 width=394)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..31.77 rows=1777 width=8)
-> Hash (cost=100.17..100.17 rows=1685 width=390)
-> Seq Scan on tbl_approves r (cost=0.00..100.17 rows=1685 width=390)
Filter: (status <> 0)