我有一个查询,例如:
SELECT count(id), pro.country_code
FROM profiles AS pro
WHERE id IN (SELECT profile_id FROM reports)
GROUP BY pro.country_code;
我的问题:
Redshift IN CLAUSE 中可以使用多少个项目?每次执行外部查询时,存储实际的 id 而不是子 sql 语句必须更快,对吗?
最佳答案
据我所知,没有限制,但如果您要携带大量数据,则可以使用。
SELECT count(id),
pro.country_code
FROM profiles AS pro
WHERE exists (SELECT profile_id FROM reports where pro.id=reports.profile_id)
GROUP BY pro.country_code;
应该更快
您也可以使用 intersect 代替 in
关于amazon-redshift - Redshift : Max items within "IN clause"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38452387/