我想为SAP ASE数据库实现分区修剪,但似乎没有使用分区。
以下是我的问题的最小可验证示例:
我创建了一个表:
create table Employee(
empId INT not null,
empName VARCHAR(50) not null,
CONSTRAINT Employee_bk PRIMARY KEY(empId)
)
partition by range (empId)
(
Employee_p1 values <= (5),
Employee_p2 values <= (10),
Employee_p3 values <= (15),
Employee_p4 values <= (20)
)
将以下数据插入表格中:
empId empName
1 hskf
6 fdgfh
8 kygj
15 zcc
17 xvx
当我从表中选择时,查询返回正确的记录:
1>select * from Employee where empId=6
2>go
empId empName
----------- --------------------------------------------------
6 fdgfh
问题是查询计划显示查询正在扫描所有分区而不是消除其他分区扫描:
STEP 1
The type of query is SELECT.
1 operator(s) under root
|ROOT:EMIT Operator (VA = 1)
|
| |SCAN Operator (VA = 0)
| | FROM TABLE
| | Employee
| | [ Partitions Used: 4, Eliminated: 0]
| | [ Eliminated Partition ids : ]
| | [ Used Partition ids : ]
| | [ Using Dynamic Partition Elimination ]
| | Using Clustered Index.
| | Index : Employee_bk
| | Forward Scan.
| | Positioning by key.
| | Keys are:
| | empId ASC
| | Using I/O Size 2 Kbytes for data pages.
| | With LRU Buffer Replacement Strategy for data pages.
根据文档,设置启用语义分区设置为1.
有人可以建议如何消除不必要的分区扫描吗?
答案 0 :(得分:0)
可能的解决方案是数据库设置
basic_optimization_partitions
已关闭。检查此设置是否已禁用,以及启用此设置时分区修剪是否有效。