【问题标题】:redshift sql current_date get_date() performance issueredshift sql current_date get_date() 性能问题
【发布时间】:2016-05-09 15:15:14
【问题描述】:
我想知道在redshift SQL上使用current_date或get_date()函数与直接使用'2016-05-05'相比是否会降低查询性能。
示例 1:
选择
*
从
表一
其中时间 >= current_date - 1
和时间
示例 2:
选择
*
从表 a
其中时间 >='2016-05-08'
和时间
示例 1 或示例 2 的性能会更好吗?还是两者都一样?
希望有人能解释一下
【问题讨论】:
标签:
sql
performance
amazon-redshift
psql
【解决方案1】:
我刚刚遇到了这个,所以我将分享我的轶事经验:
select * from table where ts > current_date limit 20 运行了 10 多分钟,然后我不耐烦并杀死了它。
select * from table where ts > '2017-06-08' limit 20 在 16 秒内完成。
表在ts上有一个排序键,并且是新分析的