QUERY PLAN
Sort (cost=100.80..100.80 rows=1 width=362)
Sort Key: p.end_at DESC
-> Group (cost=100.78..100.79 rows=1 width=362)
Group Key: p.id, client.id
-> Sort (cost=100.78..100.78 rows=1 width=346)
Sort Key: p.id, client.id
-> Nested Loop Left Join (cost=0.28..100.77 rows=1 width=346)
-> Seq Scan on tbl_pre_sales p (cost=0.00..92.46 rows=1 width=342)
Filter: (case_id = 9232)
-> Index Only Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..8.29 rows=1 width=4)
Index Cond: (id = p.client_id)