QUERY PLAN
Limit (cost=0.07..41.32 rows=1 width=514)
-> Result (cost=0.07..41.32 rows=1 width=514)
-> Sort (cost=0.07..0.07 rows=1 width=482)
Sort Key: bargain_date DESC, created_at DESC
-> HashAggregate (cost=0.00..0.06 rows=1 width=482)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=370)
One-Time Filter: false
SubPlan 1
-> Aggregate (cost=41.18..41.19 rows=1 width=32)
-> Seq Scan on tbl_invoices i (cost=0.00..41.17 rows=1 width=6)
Filter: (project_id = id)