QUERY PLAN
Limit (cost=0.07..36.78 rows=1 width=518)
-> Result (cost=0.07..36.78 rows=1 width=518)
-> Sort (cost=0.07..0.07 rows=1 width=486)
Sort Key: bargain_date DESC, created_at DESC
-> HashAggregate (cost=0.00..0.06 rows=1 width=486)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=374)
One-Time Filter: false
SubPlan 1
-> Aggregate (cost=36.64..36.65 rows=1 width=32)
-> Seq Scan on tbl_invoices i (cost=0.00..36.64 rows=1 width=6)
Filter: (project_id = id)