QUERY PLAN
Unique (cost=382.70..382.70 rows=1 width=13)
-> Sort (cost=382.70..382.70 rows=1 width=13)
Sort Key: lp.product_id, ppr.id DESC
-> Hash Join (cost=322.61..382.69 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=322.16..322.16 rows=30 width=8)
-> Subquery Scan on lp (cost=321.71..322.16 rows=30 width=8)
-> Unique (cost=321.71..321.86 rows=30 width=16)
-> Sort (cost=321.71..321.78 rows=30 width=16)
Sort Key: ppr_1.product_id, p.created_at DESC, p.id DESC
-> Nested Loop Left Join (cost=207.06..320.97 rows=30 width=16)
-> Hash Join (cost=206.79..311.19 rows=30 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=55 width=8)
Filter: ((amount IS NOT NULL) AND (product_id = ANY ('{1562,994,1339,2233,1340,1584,2262,2171,2266,2268,2270,2091,2090,1241,1528,2242,2263,2264,2255,2074}'::integer[])))
-> Hash (cost=185.50..185.50 rows=1703 width=16)
-> Seq Scan on tbl_projects p (cost=0.00..185.50 rows=1703 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)