QUERY PLAN
Sort (cost=100.71..100.72 rows=1 width=362)
Sort Key: p.end_at DESC
-> Group (cost=100.69..100.70 rows=1 width=362)
Group Key: p.id, client.id
-> Sort (cost=100.69..100.69 rows=1 width=346)
Sort Key: p.id, client.id
-> Nested Loop Left Join (cost=0.28..100.68 rows=1 width=346)
-> Seq Scan on tbl_pre_sales p (cost=0.00..92.38 rows=1 width=342)
Filter: (case_id = 9240)
-> 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)