版本:3.1.7 存算一体
问题:
根据 where date_format(a.date, ‘%Y%m’) = ‘202402’ 查询会同时扫描1月份和2月份的分区数据
但如果是 date>=‘2024-02-01’ and date<‘2024-03-01’ 则只扫描2月份的分区数据
表结构:
create table t1 (
id varchar(65533) not null,
date datime not null,
c1 varchar(65533)
) ENGINE=OLAP
PRIMARY KEY(`id`, `date`, `c1`)
PARTITION BY RANGE(`date`)
PARTITION p202401 VALUES [("2024-01-01 00:00:00"), ("2024-02-01 00:00:00")),
PARTITION p202402 VALUES [("2024-02-01 00:00:00"), ("2024-03-01 00:00:00")),
PARTITION p202403 VALUES [("2024-03-01 00:00:00"), ("2024-04-01 00:00:00")),
PARTITION p202404 VALUES [("2024-04-01 00:00:00"), ("2024-05-01 00:00:00")),
PARTITION p202405 VALUES [("2024-05-01 00:00:00"), ("2024-06-01 00:00:00")),
PARTITION p202406 VALUES [("2024-06-01 00:00:00"), ("2024-07-01 00:00:00")))
DISTRIBUTED BY HASH(`c1`) BUCKETS 1
PROPERTIES (
"replication_num" = "3",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "MONTH",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"dynamic_partition.start" = "-2147483648",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"dynamic_partition.buckets" = "1",
"dynamic_partition.history_partition_num" = "0",
"dynamic_partition.start_day_of_month" = "1",
"in_memory" = "false",
"enable_persistent_index" = "true",
"replicated_storage" = "false",
"compression" = "LZ4"
);