QUERY PLAN
Aggregate (cost=1559.80..1559.81 rows=1 width=8)
-> Sort (cost=1557.42..1557.82 rows=159 width=477)
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=1549.22..1551.60 rows=159 width=477)
Group Key: r.id
-> Hash Left Join (cost=214.20..1544.14 rows=2030 width=22)
Hash Cond: (r.id = dt1.object_id)
-> Hash Right Join (cost=197.54..1519.57 rows=2030 width=22)
Hash Cond: (rccr.approve_id = r.id)
Filter: ((r.created_by = ANY ('{5493,5495}'::integer[])) OR (rccr.user_id = 5495) OR (rvr.user_id = 5495) OR (rcvr.user_id = 5495))
-> Seq Scan on tbl_approve_carbon_copy_rels rccr (cost=0.00..30.40 rows=2040 width=8)
-> Hash (cost=124.49..124.49 rows=5844 width=34)
-> Hash Right Join (cost=48.34..124.49 rows=5844 width=34)
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=36.29..36.29 rows=964 width=30)
-> Hash Right Join (cost=13.99..36.29 rows=964 width=30)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..19.70 rows=970 width=8)
-> Hash (cost=12.00..12.00 rows=159 width=30)
-> Seq Scan on tbl_approves r (cost=0.00..12.00 rows=159 width=30)
Filter: (status <> 0)
-> Hash (cost=16.62..16.62 rows=3 width=4)
-> Seq Scan on tbl_term_taxonomy_relationships dt1 (cost=0.00..16.62 rows=3 width=4)
Filter: (term_id = 17)