QUERY PLAN
Aggregate (cost=696.97..696.98 rows=1 width=8)
-> Sort (cost=696.95..696.96 rows=1 width=389)
Sort Key: r.status, r.created_at DESC
-> Group (cost=696.94..696.94 rows=1 width=389)
Group Key: r.id
-> Sort (cost=696.94..696.94 rows=1 width=14)
Sort Key: r.id
-> Nested Loop Left Join (cost=568.52..696.93 rows=1 width=14)
-> Hash Right Join (cost=568.23..688.61 rows=1 width=14)
Hash Cond: (rccr.approve_id = r.id)
Filter: ((r.created_by = 5252) OR (rccr.user_id = 5252) OR (rvr.user_id = 5252))
-> Seq Scan on tbl_approve_carbon_copy_rels rccr (cost=0.00..96.78 rows=6278 width=8)
-> Hash (cost=568.22..568.22 rows=1 width=22)
-> Hash Right Join (cost=523.67..568.22 rows=1 width=22)
Hash Cond: (rvr.approve_id = r.id)
-> Seq Scan on tbl_approve_verify_rels rvr (cost=0.00..38.81 rows=2181 width=8)
-> Hash (cost=523.66..523.66 rows=1 width=22)
-> Seq Scan on tbl_approves r (cost=0.00..523.66 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))