QUERY PLAN
Unique (cost=391.35..391.36 rows=1 width=13)
-> Sort (cost=391.35..391.36 rows=1 width=13)
Sort Key: lp.product_id, ppr.id DESC
-> Hash Join (cost=328.56..391.34 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..50.48 rows=2344 width=17)
Filter: (amount IS NOT NULL)
-> Hash (cost=328.12..328.12 rows=29 width=8)
-> Subquery Scan on lp (cost=327.69..328.12 rows=29 width=8)
-> Unique (cost=327.69..327.83 rows=29 width=16)
-> Sort (cost=327.69..327.76 rows=29 width=16)
Sort Key: ppr_1.product_id, p.created_at DESC, p.id DESC
-> Nested Loop Left Join (cost=208.49..326.98 rows=29 width=16)
-> Hash Join (cost=208.21..317.53 rows=29 width=16)
Hash Cond: (ppr_1.project_id = p.id)
-> Seq Scan on tbl_project_product_rels ppr_1 (cost=0.00..109.18 rows=54 width=8)
Filter: ((amount IS NOT NULL) AND (product_id = ANY ('{1373,1562,851,1340,2230,1973,994,2233,1339,2262,1584,2266,2268,2270,1241,2090,1528,2242,2263,2264}'::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)