【发布时间】:2021-03-28 05:58:43
【问题描述】:
我正在尝试在 redshift 中编写一个查询,该查询在内部连接中有一个“BETWEEN”。在 Redshift 中,我知道这可能非常昂贵,但我想不出另一种写法。似乎我的查询与粘贴的链接完全相同,但在该问题中没有显示答案。有谁知道如何重写此查询以避免笛卡尔积?
Redshift - Simplify Query Plan
select a.ip, a.userid, b.city, b.country, b.ip_start, b.ip_end
from usertable a
left join ip_table on a.ip between b.ip_start and b.ip_end
在应用数据类型和排序/分布键的情况下,我尝试了多种可能性,但似乎对我的查询没有任何帮助。
ip and ip_start/ip_end = bigint- 排序键应用于
ip_start/ip_end和ip - 分发密钥应用于
ip和ip_start
【问题讨论】:
标签: sql amazon-redshift amazon-redshift-spectrum