5.10.5. Partitioning and Constraint Exclusion
5.10.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 is only applied during query planning; unlike partition pruning, it cannot be applied during query execution.
•约束排除仅在执行计划期间有效;与分区排除不同,约束排除在执行期间无效。
• 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.10.5. Partitioning and Constraint Exclusion相关推荐

  1. 5.11.5. Partitioning and Constraint Exclusion

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

  2. Oracle 19c VLDB and Partitioning Guide 第4章:分区管理 读书笔记

    本文为Oracle 19c VLDB and Partitioning Guide第4章Partition Administration的读书笔记. 使用分区表和索引时,分区管理是一项重要任务. 本章 ...

  3. JZOJ 5925. 【NOIP2018模拟10.25】naive 的瓶子

    Description 众所周知,小 naive 有 n 个瓶子,它们在桌子上排成一排.第 i 个瓶子的颜色为 ci,每个瓶子都有灵性,每次操作可以选择两个相邻的瓶子,消耗他们颜色的数值乘积的代价将其 ...

  4. 创建和使用约束Constraint

    约束(Constraint)是Microsoft SQL Server 提供的自动保持数据库完整性的一种方法,定义了可输入表或表的单个列中的数据的限制条件(有关数据完整性的介绍请参见第9 章).在SQ ...

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

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

  6. CVPR2020及ICRA2020中视觉定位论文集锦

    1.         Hierarchical Scene Coordinate Classification and Regression for Visual Localization https ...

  7. (DBA之路【五】)关于锁的故事

    首先很抱歉:这篇文章我其实整合了很多别人的文章,但是因为太多,一开始被没留意出处所以很难声明来源,很抱歉,但是这篇文章只用来作为学习笔记,作为新手,我以后会注意的. (一):什么是锁: 我觉得锁这个东 ...

  8. myeclipse使用maven整合ssh配置

    最近写项目,由于公司需求,使用myeclispe来开发maven项目,关于maven就不再介绍,无论是jar包管理功能,还是作为版本构建工具,优点自然是很多,下面先贴出所需要的配置文件. maven所 ...

  9. Mybatis【一对多、多对一、多对多】知识要点

    Mybatis[多表连接] 我们在学习Hibernate的时候,如果表涉及到两张的话,那么我们是在映射文件中使用<set>..<many-to-one>等标签将其的映射属性关联 ...

最新文章

  1. phpcms v9 数据库操作函数
  2. c拆分字符串,并按照指定格式存入结构体数组
  3. c#.net连接access操作类(转)
  4. SD-WAN应用可见性的流量对称
  5. cvid matlab,WAKE-WIN10-SOFT-软件-Matlab配置及工具箱
  6. Mybatis查询日期范围
  7. [Django]网页中利用ajax实现批量导入数据功能
  8. zabbix_server 报警
  9. 工作41:解决vuex刷新数据丢失
  10. 解决: Your ApplicationContext is unlikely to start due to a @ComponentScan of the default
  11. Python笔记-uiautomator2环境搭建(安卓模拟器测试环境+windows开发环境)
  12. MySQL基础——数据库和SQL概述\MySQL基本使用\DQL语言学习\条件查询\排序查询\常见函数\分组查询\连接查询\子查询\分页查询\联合查询
  13. 桌面上计算机右键管理打不开,Windows7中无法打开右键计算机的“管理”选项
  14. java jvm bind解决_java web项目启动的时候JVM_Bind,真的是tomcat端口被占用了吗?tomcat不同意...
  15. c#抽取pdf文档标题(1)
  16. 算法资料:算法导论_原书第3版(中文)(PDF带书签)
  17. mi5splus android9,小米MIUI 9.5国际版稳定版开始推送:超30款机型将获更新
  18. 通过热透镜聚焦的高斯光束
  19. 公司游玩出行最美的去处,收获满满的华创
  20. 用python爬取小说章节内容

热门文章

  1. ASP.netCore 笔记整理(自用)
  2. Java-----网络编程
  3. uni-app入门:WXML数据绑定
  4. 业余学Python是如何挣钱的?总结下利用Python赚外快的方法,闲余时间2k~5k
  5. 现在有什么兼职刚刚起步,将来会火?
  6. C/C++数据结构(六) —— 循环队列
  7. linux的vi编辑器课件,Linux课件vi编辑器的使用.ppt
  8. PHP-Opcache优化
  9. 塑料周转箱的低碳环保之路
  10. Unity3d 学习与应用之 DEBUG