QUERY PLAN
Unique (cost=389.06..389.07 rows=1 width=13)
-> Sort (cost=389.06..389.07 rows=1 width=13)
Sort Key: lp.product_id, ppr.id DESC
-> Hash Join (cost=329.19..389.05 rows=1 width=13)
Hash Cond: ((ppr.project_id = lp.project_id) AND (ppr.product_id = lp.product_id))
-> Seq Scan on tbl_project_product_rels ppr (cost=0.00..48.22 rows=2218 width=17)
Filter: (amount IS NOT NULL)
-> Hash (cost=328.72..328.72 rows=31 width=8)
-> Subquery Scan on lp (cost=328.26..328.72 rows=31 width=8)
-> Unique (cost=328.26..328.41 rows=31 width=16)
-> Sort (cost=328.26..328.33 rows=31 width=16)
Sort Key: ppr_1.product_id, p.created_at DESC, p.id DESC
-> Hash Right Join (cost=311.15..327.49 rows=31 width=16)
Hash Cond: (prr.project_id = p.id)
-> Seq Scan on tbl_project_remind_receivers prr (cost=0.00..13.19 rows=819 width=4)
-> Hash (cost=310.76..310.76 rows=31 width=16)
-> Hash Join (cost=206.84..310.76 rows=31 width=16)
Hash Cond: (ppr_1.project_id = p.id)
-> Seq Scan on tbl_project_product_rels ppr_1 (cost=0.00..103.77 rows=58 width=8)
Filter: ((amount IS NOT NULL) AND (product_id = ANY ('{2177,1558,2171,2261,2262,2269,1562,1584,2270,1372,1241,2091,2090,1528,2242,2268,2267,2265,2266,2263}'::integer[])))
-> Hash (cost=185.55..185.55 rows=1703 width=16)
-> Seq Scan on tbl_projects p (cost=0.00..185.55 rows=1703 width=16)
Filter: (project_status = 3)