QUERY PLAN
Sort (cost=82.03..82.03 rows=2 width=262)
Sort Key: p.updated_at DESC
-> GroupAggregate (cost=81.97..82.02 rows=2 width=262)
Group Key: p.id, project.id, client.id
-> Sort (cost=81.97..81.97 rows=2 width=231)
Sort Key: p.id, project.id, client.id
-> Nested Loop (cost=0.84..81.96 rows=2 width=231)
-> Nested Loop Left Join (cost=0.56..65.36 rows=2 width=84)
Join Filter: (ppr.project_id = project.id)
-> Seq Scan on tbl_project_product_rels ppr (cost=0.00..48.73 rows=2 width=17)
Filter: (project_id = 4014)
-> Materialize (cost=0.56..16.61 rows=1 width=71)
-> Nested Loop Left Join (cost=0.56..16.60 rows=1 width=71)
-> Index Scan using tbl_projects_pkey on tbl_projects project (cost=0.28..8.30 rows=1 width=30)
Index Cond: (id = 4014)
-> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..8.29 rows=1 width=45)
Index Cond: (project.client_id = id)
-> Index Scan using tbl_products_pkey on tbl_products p (cost=0.28..8.29 rows=1 width=151)
Index Cond: (id = ppr.product_id)