QUERY PLAN
Limit (cost=0.07..39.19 rows=1 width=516)
-> Result (cost=0.07..39.19 rows=1 width=516)
-> Sort (cost=0.07..0.07 rows=1 width=484)
Sort Key: bargain_date DESC, created_at DESC
-> HashAggregate (cost=0.00..0.06 rows=1 width=484)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=372)
One-Time Filter: false
SubPlan 1
-> Aggregate (cost=39.05..39.06 rows=1 width=32)
-> Seq Scan on tbl_invoices i (cost=0.00..39.05 rows=1 width=6)
Filter: (project_id = id)