5.11.5. Partitioning and Constraint Exclusion

5.11.5.分区和约束排除

Constraint exclusion is a query optimization technique similar to partition pruning. While it is primarily used for partitioning implemented using the legacy inheritance method, it can be used for other purposes, including with declarative partitioning.

约束排除是一个类似于分区排除的查询优化技术。虽然它主要用于使用继承方法实现的分区,但它也可以用于其他目的,包括原生分区。

Constraint exclusion works in a very similar way to partition pruning, except that it uses each table's CHECK constraints — which gives it its name — whereas partition pruning uses the table's partition bounds, which exist only in the case of declarative partitioning. Another difference is that constraint exclusion is only applied at plan time; there is no attempt to remove partitions at execution time.

约束排除的工作方式与分区排除类似,除了约束排除使用表的检查约束(为其命名),而分区排除使用仅原生分区支持的表分区边界。另一个不同点在于,约束排除仅在生成执行计划阶段有用,而在执行阶段无效。

The fact that constraint exclusion uses CHECK constraints, which makes it slow compared to partition pruning, can sometimes be used as an advantage: because constraints can be defined even on declaratively-partitioned tables, in addition to their internal partition bounds, constraint exclusion may be able to elide additional partitions from the query plan.

虽然约束排除使用了检查约束,这使得其与分区排除比起来慢很多,但有时候,这可以变为优势: 因为甚至可以在原生分区的表上定义约束,所以除了其内部分区边界外,约束排除还可以帮助从查询计划中排除其他更多分区。

The default (and recommended) setting of constraint_exclusion is neither on nor off, but an intermediate setting called partition, which causes the technique to be applied only to queries that are likely to be working on inheritance partitioned tables. The on setting causes the planner to examine CHECK constraints in all queries, even simple ones that are unlikely to benefit.

constraint_exclusion的默认值(也是推荐值)既不是on也不是off,而是partition, 这使得该技术仅应用于可能在继承分区表上运行的查询。 on设置使执行计划时检查所有查询中的CHECK约束,即使是那些不太可能受益的简单查询也会如此。

The following caveats apply to constraint exclusion:

约束排除有关注意事项如下:

•约束排除仅在执行计划期间有效;与分区排除不同,约束排除在执行期间无效。

• Constraint exclusion only works when the query's WHERE clause contains constants (or externally supplied parameters). For example, a comparison against a non-immutable function such as CURRENT_TIMESTAMP cannot be optimized, since the planner cannot know which child table the function's value might fall into at run time.

• 约束排除仅在查询的WHERE子句包含常量(或外部提供的参数)时有效。 例如,无法优化与诸如CURRENT_TIMESTAMP之类的不可修改函数的比较,因为执行计划无法在运行时知道该函数的值可能属于哪个子表。

• Keep the partitioning constraints simple, else the planner may not be able to prove that child tables might not need to be visited. Use simple equality conditions for list partitioning, or simple range tests for range partitioning, as illustrated in the preceding examples. A good rule of thumb is that partitioning constraints should contain only comparisons of the partitioning column(s) to constants using B-tree-indexable operators, because only B-tree-indexable column(s) are allowed in the partition key.

•分区约束要简单,否则的话执行计划可能无法明确哪个子表不需要访问。如上例所示,对列表分区使用简单的相等条件,对范围分区使用简单的范围测试。一个好的经验法则是,分区约束应只包含使用B-tree-indexable运算符的分区列与常量的比较,因为在分区键中仅允许B-tree-indexable列。

• All constraints on all children of the parent table are examined during constraint exclusion, so large numbers of children are likely to increase query planning time considerably. So the legacy inheritance based partitioning will work well with up to perhaps a hundred child tables; don't try to use many thousands of children.

•约束排除会检查父表的所有子表中的所有约束,所以大量的子表会显著提高查询时间。因此,基于继承的分区最多也就有几百个子表;千万不要尝试使用几千个子表。

5.11.5. Partitioning and Constraint Exclusion相关推荐

  1. 5.10.5. Partitioning and Constraint Exclusion

    5.10.5. Partitioning and Constraint Exclusion 5.10.5.分区和约束排除 Constraint exclusion is a query optimiz ...

  2. probe request帧结构_WIFI基础知识(802.11)

    1. WEP,Wired Equivalent Privacy: 802.11中最早期的加密标准 2. CCMP(CTR with CBC-MAC Protocol): 基于AES的全新加密协议,在I ...

  3. WIFI:802.11协议帧格式

    802协议桢格式 802.11和Wi-Fi技术并不是同一个东西.Wi-Fi标准是802.11标准的一个子集,并且是Wi-Fi联盟负责管理 802协议桢格式: 协议 发布年份/日期 Op.标准频宽 实际 ...

  4. 802.11协议帧格式、Wi-Fi连接交互过程、无线破解入门

    转自: http://www.cnblogs.com/littlehann/p/3700357.html Linux黑客大曝光: 第8章 无线网络 无线网络安全攻防实战进阶 无线网络安全 黑客大曝光 ...

  5. PostgreSQL 优化器逻辑推理能力 源码解析

    数据库优化器需要具备逻辑推理能力,而且越强越好,为什么呢? 举一些例子, 通过已知的一个人讲的是真话,推理另一个人讲的一定是真话或一定是假话. 例子1: 假设预先提供了 a > 10 是真话 可 ...

  6. Java分布式内存开源实现:Hazelcast

    Hazelcast是一个Java的开源分布式内存实现,它具有以下特性: 01    Distributed implementations of java.util.{Queue, Set, List ...

  7. PostgreSQL在何处处理 sql查询之五十二

    开始 /** Ready to do the primary planning.*/final_rel = make_one_rel(root, joinlist); 展开: /** make_one ...

  8. postgresql中表的继承及分区表(四)

    2019独角兽企业重金招聘Python工程师标准>>> 分区查询优化-Constraint Exclusion Oracle中这种技术叫分区裁剪(Partition Pruning) ...

  9. Oracle12c与Oracle11g采用触发器与存储过程实现同步更新(代码+图解)

    一.保证两台笔记本网络互通 关于连接,详情见之前写的:WIFI网络,两台笔记本互联Oracle,一台是11g,一台是12c 现在测试的ip地址: A: 10.65.252.84 B: 10.82.15 ...

最新文章

  1. 超详细中文预训练模型ERNIE使用指南
  2. 用DIV+Javascript实现标签功能
  3. .net Redis使用公共方法引用CSRedisCore
  4. Java-Runoob:Java Stream、File、IO
  5. hdu1403 后缀数组
  6. Android之百度地图定位最详细使用总结
  7. 深度相机(二)--结构光深度测距
  8. 用PHP的CURL写的一个采集Discuz的例子
  9. mysql int的长度
  10. Node文件服务器(文件上传)
  11. pandas数据处理、绘图
  12. QT 车牌号正则验证
  13. 标准粒子群算法(PSO)
  14. Dotnet WebAPI 项目启动提示 500.30 - ANCM In-Process Start Failure
  15. 阿兹特克码(Aztec)的介绍及如何生成
  16. python 回溯法 01背包问题_Python基于回溯法解决01背包问题实例
  17. 个人如何搭建云手机出租?ARM服务器搭建机房教程
  18. 微信小程序学习总结(4.wx:if按钮切换)
  19. BadRabbit勒索病毒分析
  20. logrotate测试_logrotate 日志管理

热门文章

  1. Java线程状态完全解析教程
  2. 应用程序无法正常启动0xc000007b的一个解决办法
  3. odoo 创建向导wizard页面
  4. 基于Android studio的校园小助手app设计
  5. 新版“禁塑令”,促可降解塑料替代进程加快
  6. 【AI名利场·公司】也喊All in AI,看出门问问的新战略
  7. JDK8和JDK9双版本共存
  8. 支持度(support)和置信度(confidence)
  9. Anycast功能原理OSPF报文分析-上手必看
  10. 备战2020,软件测试工程师面试题集锦