QUERY PLAN
Unique (cost=390.82..390.83 rows=1 width=13)
-> Sort (cost=390.82..390.82 rows=1 width=13)
Sort Key: lp.product_id, ppr.id DESC
-> Hash Join (cost=330.73..390.81 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.36 rows=2232 width=17)
Filter: (amount IS NOT NULL)
-> Hash (cost=330.02..330.02 rows=47 width=8)
-> Subquery Scan on lp (cost=329.32..330.02 rows=47 width=8)
-> Unique (cost=329.32..329.55 rows=47 width=16)
-> Sort (cost=329.32..329.44 rows=47 width=16)
Sort Key: ppr_1.product_id, p.created_at DESC, p.id DESC
-> Nested Loop Left Join (cost=208.49..328.01 rows=47 width=16)
-> Hash Join (cost=208.21..312.70 rows=47 width=16)
Hash Cond: (ppr_1.project_id = p.id)
-> Seq Scan on tbl_project_product_rels ppr_1 (cost=0.00..104.26 rows=87 width=8)
Filter: ((amount IS NOT NULL) AND (product_id = ANY ('{2265,2177,2261,867,868,1558,2231,989,2232,969,870,1372,2269,1943,1373,1025,2267,1339,2230,2233}'::integer[])))
-> Hash (cost=186.78..186.78 rows=1715 width=16)
-> Seq Scan on tbl_projects p (cost=0.00..186.78 rows=1715 width=16)
Filter: (project_status = 3)
-> Index Only Scan using tbl_project_remind_receivers_project_user_idx on tbl_project_remind_receivers prr (cost=0.28..0.32 rows=1 width=4)
Index Cond: (project_id = p.id)