mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Support "x IS NOT NULL" clauses as indexscan conditions. This turns out
to be just a minor extension of the previous patch that made "x IS NULL" indexable, because we can treat the IS NOT NULL condition as if it were "x < NULL" or "x > NULL" (depending on the index's NULLS FIRST/LAST option), just like IS NULL is treated like "x = NULL". Aside from any possible usefulness in its own right, this is an important improvement for index-optimized MAX/MIN aggregates: it is now reliably possible to get a column's min or max value cheaply, even when there are a lot of nulls cluttering the interesting end of the index.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.215 2009/12/29 20:11:42 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.216 2010/01/01 21:53:48 tgl Exp $ -->
|
||||
<!--
|
||||
Documentation of the system catalogs, directed toward PostgreSQL developers
|
||||
-->
|
||||
@ -466,7 +466,7 @@
|
||||
<entry><structfield>amsearchnulls</structfield></entry>
|
||||
<entry><type>bool</type></entry>
|
||||
<entry></entry>
|
||||
<entry>Does the access method support IS NULL searches?</entry>
|
||||
<entry>Does the access method support IS NULL/NOT NULL searches?</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.31 2009/07/29 20:56:17 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.32 2010/01/01 21:53:49 tgl Exp $ -->
|
||||
|
||||
<chapter id="indexam">
|
||||
<title>Index Access Method Interface Definition</title>
|
||||
@ -134,7 +134,8 @@
|
||||
null values. An index access method that sets
|
||||
<structfield>amindexnulls</structfield> may also set
|
||||
<structfield>amsearchnulls</structfield>, indicating that it supports
|
||||
<literal>IS NULL</> clauses as search conditions.
|
||||
<literal>IS NULL</> and <literal>IS NOT NULL</> clauses as search
|
||||
conditions.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.79 2009/08/07 20:54:31 alvherre Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.80 2010/01/01 21:53:49 tgl Exp $ -->
|
||||
|
||||
<chapter id="indexes">
|
||||
<title id="indexes-title">Indexes</title>
|
||||
@ -147,8 +147,8 @@ CREATE INDEX test1_id_index ON test1 (id);
|
||||
|
||||
Constructs equivalent to combinations of these operators, such as
|
||||
<literal>BETWEEN</> and <literal>IN</>, can also be implemented with
|
||||
a B-tree index search. Also, an <literal>IS NULL</> condition on
|
||||
an index column can be used with a B-tree index.
|
||||
a B-tree index search. Also, an <literal>IS NULL</> or <literal>IS NOT
|
||||
NULL</> condition on an index column can be used with a B-tree index.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -180,8 +180,7 @@ 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
|
||||
<literal>=</literal> operator. (Hash indexes do not support
|
||||
<literal>IS NULL</> searches.)
|
||||
<literal>=</literal> operator.
|
||||
The following command is used to create a hash index:
|
||||
<synopsis>
|
||||
CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> USING hash (<replaceable>column</replaceable>);
|
||||
@ -1025,7 +1024,7 @@ SELECT am.amname AS index_method,
|
||||
real statistics, some default values are assumed, which are
|
||||
almost certain to be inaccurate. Examining an application's
|
||||
index usage without having run <command>ANALYZE</command> is
|
||||
therefore a lost cause.
|
||||
therefore a lost cause.
|
||||
See <xref linkend="vacuum-for-statistics" endterm="vacuum-for-statistics-title">
|
||||
and <xref linkend="autovacuum" endterm="autovacuum-title"> for more information.
|
||||
</para>
|
||||
|
Reference in New Issue
Block a user