Redshift高频查询持续触发段编译的原因排查求助
Redshift查询频繁触发编译的问题排查
我们在Redshift中运行范围限制查询,仅employee_id和business_date参数会变化,但SVL_COMPILE显示每时段编译量极高,多数查询都需要编译,增加了查询耗时。该查询由产品团队以不同employee_id和business_date范围执行,每小时请求量达1500次。
相关信息
- business_date字段格式为
yyyy-MM-dd; - tillTime为时间戳字段,活跃记录值固定为
9999-01-01 01:00:00; - 查询由部署在10台EC2实例上的Spring Boot应用发起;
- employee_id最多为1-5个;
- business_date范围为1-30天;
- 表含216列,查询SELECT的列根据用户选择动态生成。
原查询语句
Select columns from accounts table where business_date between (?) and (?) and employee_id in (?) and sysdate > tillTime;
表配置
SORTKEY(business_date, employee_id, snap_type, tillTime) Diststyle: AUTO(EVEN)
集群配置
Node type: ra3.xlplus Number of nodes: 10
尝试的优化查询
我们尝试修改查询为:
Select columns from accounts table where business_date between (?) and (?) and employee_id in (?) and tillTime='9999-01-01 01:00:00';
但性能未明显改善。
核心疑问
为何无论使用sysdate > tillTime还是tillTime='9999-01-01 01:00:00'都会触发频繁编译?
内容的提问来源于stack exchange,提问作者Rahi c
相关产品推荐
相关产品推荐

