QUERY PLAN
Sort (cost=46.72..46.73 rows=1 width=42)
Sort Key: pc.serial_no
-> Group (cost=46.70..46.71 rows=1 width=42)
Group Key: pc.id, pcr.project_id
-> Sort (cost=46.70..46.71 rows=1 width=23)
Sort Key: pc.id
-> Nested Loop (cost=0.28..46.69 rows=1 width=23)
-> Seq Scan on tbl_purchase_client_rels pcr (cost=0.00..38.39 rows=1 width=8)
Filter: (project_id = 3854)
-> Index Scan using tbl_purchase_contracts_pkey on tbl_purchase_contracts pc (cost=0.28..8.30 rows=1 width=19)
Index Cond: (id = pcr.contract_id)
Filter: (cost_type = 1)