amazon-redshift - Redshift - IN 子句中的参数使查询重新编译
问题描述
我有一个带有 IN 子句的过滤器,可以从我的查询中的用户选择中获取 CustomerID。我正在对查询执行进行基准测试,似乎是通过更改编号。redshift 中 IN 子句中的参数数量会导致重新编译查询。IN 子句中的参数更改后运行的后续查询比上一次运行花费更多时间。
select * -- some aggregations here
from FactCustomer c
inner join FactSales s on c.CustomerID = s.CustomerId
inner join DimDate d on d.DateID = s.DateID
inner join DimTime t on t.TimeID = d.timeID
where d.SalesDate between '01-01-2018' and '12-31-2018'
and c.CustomerID in ( 1,3,7,9, 11, 13, 15, 17, 19, 21, 23, 25, 27 )
-- there are over 200 customers and the user can select as much as they want in the filter
-- the customerIDs comes from the user dyamically thru the dashboard
-- if the no. of parameters in customerID change to less or more the subsequent queries take time
我的问题
Redshift 中的替代方法是什么,以便我可以从用户那里获取可在我的查询中使用的 customerIds,而无需使用 IN 子句?
PS 使用临时表不是我的选择。
任何见解表示赞赏。
解决方案
推荐阅读
- php - 如何检查用户是普通用户还是管理员用户 PHP
- php - 如何在 CPanel 上从 php 运行 Python3 脚本?
- javascript - 将类添加到单击的模态
- c# - 使用实体框架删除记录时出错
- amazon-web-services - EMR + S3:如何实现 RACK_LOCAL
- ios - 未调用云锚委托方法
- haskell - Haskell中的递归配对列表搜索
- java - 没有root权限无法在android上运行iperf3
- c - 我的代码在 C 中看不到 while 循环(带有 getchar 函数)
- ansible - 在 Ansible Playbook 中通过标签或过滤器包含角色的任务