为了更快的定位您的问题,请提供以下信息,谢谢
【详述】同一查询语句,datetime 类型 where 条件两种写法,查询耗时从26秒下降至3秒,写法1,写法3看执行计划有分区剪裁,写法2没有分区剪裁反而更快,两个执行计划不一样了,什么原因呢?同时对于datetime类型字段做查询条件时推荐的写法是怎样的呢?
WHERE
– 写法1 耗时26s
t.order_time >= cast(‘2024-05-28 00:00:00’ as datetime)
and t.order_time <= cast(‘2024-05-28 23:59:59’ as datetime)
– 写法2 耗时3s
t.order_time >= ‘20240528000000’
and t.order_time <= ‘20240528235959’
– 写法3 耗时26s
t.order_time >= ‘2024-05-28 00:00:00’
and t.order_time <= ‘2024-05-28 23:59:59’
【背景】
【业务影响】BE长时间下线不了
【是否存算分离】否
【StarRocks版本】2.5.19
【集群规模】:3fe(3 follower)+4be(3个be与fe混部)
【机器信息】CPU虚拟核/内存/网卡,40C/128G/万兆
【联系方式】StarRocks社区群5 -思变 [1412195108@qq.com]
【附件】
查询语句.txt (3.6 KB)
写法2执行计划.txt (32.4 KB) 写法1执行计划.txt (32.5 KB) 写法2查询profile.txt (363.3 KB) 写法1查询profile.txt (387.9 KB) 建表语句.txt (551.6 KB)