From f02a82b6adad1af75499c4ac7221bbd94e3c4fbf Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 6 Apr 2007 22:33:43 +0000 Subject: Make 'col IS NULL' clauses be indexable conditions. Teodor Sigaev, with some kibitzing from Tom Lane. --- doc/src/sgml/catalogs.sgml | 9 ++++++++- doc/src/sgml/indexam.sgml | 7 +++++-- doc/src/sgml/indices.sgml | 14 +++++++++----- doc/src/sgml/ref/create_index.sgml | 8 +------- 4 files changed, 23 insertions(+), 15 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 492b06de0a2..8243dd8d046 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,4 +1,4 @@ - + @@ -405,6 +405,13 @@ Does the access method support null index entries? + + amsearchnulls + bool + + Does the access method support IS NULL searches? + + amstorage bool diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index 247f7f48cbe..8b246719ccf 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -1,4 +1,4 @@ - + Index Access Method Interface Definition @@ -129,7 +129,10 @@ It is, however, OK to omit rows where the first indexed column is null. Thus, amindexnulls should be set true only if the index access method indexes all rows, including arbitrary combinations of - null values. + null values. An index access method that sets + amindexnulls may also set + amsearchnulls, indicating that it supports + IS NULL clauses as search conditions. diff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgml index 0a6defbf629..2c238d34294 100644 --- a/doc/src/sgml/indices.sgml +++ b/doc/src/sgml/indices.sgml @@ -1,4 +1,4 @@ - + Indexes @@ -147,8 +147,8 @@ CREATE INDEX test1_id_index ON test1 (id); Constructs equivalent to combinations of these operators, such as BETWEEN and IN, can also be implemented with - a B-tree index search. (But note that IS NULL is not - equivalent to = and is not indexable.) + a B-tree index search. Also, an IS NULL condition on + an index column can be used with a B-tree index. @@ -180,8 +180,9 @@ CREATE INDEX test1_id_index ON test1 (id); Hash indexes can only handle simple equality comparisons. The query planner will consider using a hash index whenever an indexed column is involved in a comparison using the - = operator. The following command is used to - create a hash index: + = operator. (But hash indexes do not support + IS NULL searches.) + The following command is used to create a hash index: CREATE INDEX name ON table USING hash (column); @@ -234,6 +235,8 @@ CREATE INDEX name ON table (See for the meaning of these operators.) + Also, an IS NULL condition on + an index column can be used with a GiST index. Many other GiST operator classes are available in the contrib collection or as separate projects. For more information see . @@ -266,6 +269,7 @@ CREATE INDEX name ON table (See for the meaning of these operators.) + GIN indexes cannot use IS NULL as a search condition. Other GIN operator classes are available in the contrib tsearch2 and intarray modules. For more information see . diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml index 69ba5d7a7a5..feebc4c164a 100644 --- a/doc/src/sgml/ref/create_index.sgml +++ b/doc/src/sgml/ref/create_index.sgml @@ -1,5 +1,5 @@ @@ -434,12 +434,6 @@ Indexes: to remove an index. - - Indexes are not used for IS NULL clauses by default. - The best way to use indexes in such cases is to create a partial index - using an IS NULL predicate. - - Prior releases of PostgreSQL also had an R-tree index method. This method has been removed because -- cgit v1.2.3