QUERY PLAN
Aggregate (cost=419.68..419.69 rows=1 width=8)
-> Sort (cost=419.53..419.56 rows=10 width=385)
Sort Key: r.created_at DESC
-> Group (cost=419.32..419.37 rows=10 width=385)
Group Key: r.id
-> Sort (cost=419.32..419.34 rows=10 width=12)
Sort Key: r.id
-> Hash Right Join (cost=53.00..419.15 rows=10 width=12)
Hash Cond: (rvr.erp_cash_cost_ticket_id = r.id)
-> Seq Scan on tbl_erp_cash_cost_ticket_verify_rels rvr (cost=0.00..294.58 rows=19058 width=4)
-> Hash (cost=52.95..52.95 rows=4 width=12)
-> Nested Loop (cost=0.28..52.95 rows=4 width=12)
-> Seq Scan on tbl_erp_cash_cost_ticket_purchase_contract_settles eptss (cost=0.00..19.75 rows=4 width=4)
Filter: (purchase_contract_id = 4042)
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets r (cost=0.28..8.30 rows=1 width=12)
Index Cond: (id = eptss.erp_cash_cost_ticket_id)