QUERY PLAN
Aggregate (cost=384.01..384.02 rows=1 width=8)
-> Sort (cost=384.00..384.00 rows=1 width=389)
Sort Key: r.status, r.created_at DESC
-> Group (cost=383.98..383.99 rows=1 width=389)
Group Key: r.id
-> Sort (cost=383.98..383.98 rows=1 width=14)
Sort Key: r.id
-> Nested Loop Left Join (cost=257.26..383.97 rows=1 width=14)
-> Hash Right Join (cost=256.97..375.65 rows=1 width=14)
Hash Cond: (rccr.approve_id = r.id)
Filter: ((r.created_by = ANY ('{1004,1001,5449,5449,5388,1013,1013,1005}'::integer[])) OR (rccr.user_id = 5388) OR (rvr.user_id = 5388))
-> Seq Scan on tbl_approve_carbon_copy_rels rccr (cost=0.00..95.53 rows=6153 width=8)
-> Hash (cost=256.96..256.96 rows=1 width=22)
-> Hash Right Join (cost=212.03..256.96 rows=1 width=22)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..39.11 rows=2211 width=8)
-> Hash (cost=212.02..212.02 rows=1 width=22)
-> Seq Scan on tbl_approves r (cost=0.00..212.02 rows=1 width=22)
Filter: ((status <> 0) AND (supplier_id = 431))
-> Index Only Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..8.31 rows=1 width=4)
Index Cond: ((object_id = r.id) AND (term_id = 17))