QUERY PLAN
Aggregate (cost=69.53..69.54 rows=1 width=8)
-> Sort (cost=69.52..69.52 rows=1 width=393)
Sort Key: r.created_at DESC
-> Group (cost=69.50..69.51 rows=1 width=393)
Group Key: r.id
-> Sort (cost=69.50..69.50 rows=1 width=12)
Sort Key: r.id
-> Hash Right Join (cost=46.14..69.49 rows=1 width=12)
Hash Cond: (rvr.erp_collect_ticket_id = r.id)
-> Seq Scan on tbl_erp_collect_ticket_verify_rels rvr (cost=0.00..19.70 rows=970 width=4)
-> Hash (cost=46.13..46.13 rows=1 width=12)
-> Nested Loop (cost=0.28..46.13 rows=1 width=12)
-> Seq Scan on tbl_erp_collect_ticket_settles ectss (cost=0.00..37.83 rows=1 width=4)
Filter: (sales_contract_id = 4075)
-> Index Scan using tbl_erp_collect_tickets_pkey on tbl_erp_collect_tickets r (cost=0.28..8.29 rows=1 width=12)
Index Cond: (id = ectss.erp_collect_ticket_id)