From e0cdd0fcf5f677b588f63b40b801e42e2ee3786d Mon Sep 17 00:00:00 2001 From: Hannes Ljungberg Date: Thu, 11 Jun 2020 21:05:38 +0200 Subject: Fixed #31649 -- Added support for covering exclusion constraints on PostgreSQL 12+. --- docs/ref/contrib/postgres/constraints.txt | 17 ++++++++++++++++- docs/releases/3.2.txt | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/ref/contrib/postgres/constraints.txt b/docs/ref/contrib/postgres/constraints.txt index f90667c394..fdc547265e 100644 --- a/docs/ref/contrib/postgres/constraints.txt +++ b/docs/ref/contrib/postgres/constraints.txt @@ -12,7 +12,7 @@ PostgreSQL supports additional data integrity constraints available from the ``ExclusionConstraint`` ======================= -.. class:: ExclusionConstraint(*, name, expressions, index_type=None, condition=None, deferrable=None) +.. class:: ExclusionConstraint(*, name, expressions, index_type=None, condition=None, deferrable=None, include=None) Creates an exclusion constraint in the database. Internally, PostgreSQL implements exclusion constraints using indexes. The default index type is @@ -106,6 +106,21 @@ enforced immediately after every command. Deferred exclusion constraints may lead to a `performance penalty `_. +``include`` +----------- + +.. attribute:: ExclusionConstraint.include + +.. versionadded:: 3.2 + +A list or tuple of the names of the fields to be included in the covering +exclusion constraint as non-key columns. This allows index-only scans to be +used for queries that select only included fields +(:attr:`~ExclusionConstraint.include`) and filter only by indexed fields +(:attr:`~ExclusionConstraint.expressions`). + +``include`` is supported only for GiST indexes on PostgreSQL 12+. + Examples -------- diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index 03f485b224..2e9c87e567 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -70,7 +70,8 @@ Minor features :mod:`django.contrib.postgres` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -* ... +* The new :attr:`.ExclusionConstraint.include` attribute allows creating + covering exclusion constraints on PostgreSQL 12+. :mod:`django.contrib.redirects` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.3