为了更快的定位您的问题,请提供以下信息,谢谢
【详述】查询SQL分区裁剪失效
【背景】目前发现在使用时间函数,或者一些特定写法时,分区裁剪会失效
【业务影响】查询数据量从单分区膨胀成全分区
【是否存算分离】
【StarRocks版本】2.5.20
【集群规模】例如:3fe +5be(独立部署)
【机器信息】Be配置16C,64GB
explain
SELECT * FROM ods.ods_hd_h2_t_sale_d_dip
WHERE dt = date_format((add_months (‘2024-06-28’, -12)),’%Y-%m-%d %H:%m:%s’)
PREAGGREGATION: ON
PREDICATES: CAST(86: dt AS DATETIME) = CAST(date_format(add_months('2024-06-28 00:00:00', -12), '%Y-%m-%d %H:%m:%s') AS DATETIME)
partitions=907/913
explain
SELECT * FROM ods.ods_hd_h2_t_sale_d_dip
WHERE dt = date_trunc(‘day’,‘2023-12-02’)
PREAGGREGATION: ON
PREDICATES: 86: dt = '2023-12-02'
partitions=1/913
explain
SELECT * FROM ods.ods_hd_h2_t_sale_d_dip
WHERE dt = date_trunc(‘day’,date_format((add_months (‘2024-06-28’, -12)),’%Y-%m-%d %H:%m:%s’))
PREAGGREGATION: ON
PREDICATES: CAST(86: dt AS DATETIME) = date_trunc('day', CAST(date_format(add_months('2024-06-28 00:00:00', -12), '%Y-%m-%d %H:%m:%s') AS DATETIME))
partitions=907/913