【问题标题】:Partition pruning/elimination in SAP ASE databaseSAP ASE 数据库中的分区修剪/消除
【发布时间】:2017-11-29 16:03:36
【问题描述】:

我想为 SAP ASE 数据库实施分区修剪,但分区似乎没有被使用。

这是我的问题的最小可验证示例:

  1. 我已经创建了一个表:

    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)
    )
    
  2. 以下数据被插入到表中:

    empId  empName
       1  hskf
       6  fdgfh
       8  kygj
      15  zcc
      17  xvx
    
  3. 当我从表中选择时,查询返回正确的记录:

    1>select * from Employee where empId=6
    2>go
    
    empId       empName
    ----------- --------------------------------------------------
    6           fdgfh
    
  4. 问题是查询计划显示查询正在扫描所有分区而不是消除其他分区扫描:

    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。

谁能建议如何消除不必要的分区扫描?

【问题讨论】:

  • 您确定表中有足够的数据来证明除前向扫描之外的任何内容吗?可能这里的问题是分区修剪根本没有好处。
  • 感谢您的回复。据我了解,分区修剪不依赖于数据大小。

标签: database database-partitioning


【解决方案1】:

可能的解决方案是数据库设置

basic_optimization_partitions 

已关闭。检查此设置是否已禁用,以及打开此设置时分区修剪是否有效。

【讨论】:

  • 感谢您的回复。启用此参数后 - 'basic_optimization_partitions: allow partitioned tables in basic optimization',它起作用了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多