amazon-redshift - Redshift : Max items within "IN clause"?

标签 amazon-redshift

我有一个查询,例如:

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/

相关文章:

python - 如何使多连接数据加载原子化?

java - 从 redshift 异步批量卸载

amazon-web-services - 在 redshift 中查询外部表时获取 0 行

sql - 在 Redshift 中按类别选择 n 个最大计数

amazon-web-services - S3 到 Redshift : Copy with Access Denied

amazon-redshift - 需要从 Redshift 中的日期列中划分月份和年份

amazon-web-services - 如何验证 Redshift 是否真的磁盘已满?

sql - 如何为对 Amazon Redshift 的原始 SQL 访问实现行级安全性 (RLS)?

sql - 如何禁用在 Redshift 查询中使用缓存结果?

sql - AWS Redshift 可以删除包含在事务中的表吗?