QUERY PLAN
Aggregate (cost=38.77..38.78 rows=1 width=8)
-> Sort (cost=38.70..38.71 rows=5 width=665)
Sort Key: p.updated_at DESC, p.id DESC
-> Group (cost=38.62..38.64 rows=5 width=665)
Group Key: p.id
-> Sort (cost=38.62..38.63 rows=5 width=12)
Sort Key: p.id DESC
-> Nested Loop (cost=0.28..38.56 rows=5 width=12)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..1.07 rows=5 width=4)
Filter: (inventory > '0'::numeric)
-> Index Scan using tbl_products_pkey on tbl_products p (cost=0.28..7.49 rows=1 width=28)
Index Cond: (id = eip.product_id)