postgresql/contrib
David Rowley b262ad440e Add better handling of redundant IS [NOT] NULL quals
Until now PostgreSQL has not been very smart about optimizing away IS
NOT NULL base quals on columns defined as NOT NULL.  The evaluation of
these needless quals adds overhead.  Ordinarily, anyone who came
complaining about that would likely just have been told to not include
the qual in their query if it's not required.  However, a recent bug
report indicates this might not always be possible.

Bug 17540 highlighted that when we optimize Min/Max aggregates the IS NOT
NULL qual that the planner adds to make the rewritten plan ignore NULLs
can cause issues with poor index choice.  That particular case
demonstrated that other quals, especially ones where no statistics are
available to allow the planner a chance at estimating an approximate
selectivity for can result in poor index choice due to cheap startup paths
being prefered with LIMIT 1.

Here we take generic approach to fixing this by having the planner check
for NOT NULL columns and just have the planner remove these quals (when
they're not needed) for all queries, not just when optimizing Min/Max
aggregates.

Additionally, here we also detect IS NULL quals on a NOT NULL column and
transform that into a gating qual so that we don't have to perform the
scan at all.  This also works for join relations when the Var is not
nullable by any outer join.

This also helps with the self-join removal work as it must replace
strict join quals with IS NOT NULL quals to ensure equivalence with the
original query.

Author: David Rowley, Richard Guo, Andy Fan
Reviewed-by: Richard Guo, David Rowley
Discussion: https://postgr.es/m/CAApHDvqg6XZDhYRPz0zgOcevSMo0d3vxA9DvHrZtKfqO30WTnw@mail.gmail.com
Discussion: https://postgr.es/m/17540-7aa1855ad5ec18b4%40postgresql.org
2024-01-23 18:09:18 +13:00
..
adminpack Update copyright for 2024 2024-01-03 20:49:05 -05:00
amcheck Update copyright for 2024 2024-01-03 20:49:05 -05:00
auth_delay Update copyright for 2024 2024-01-03 20:49:05 -05:00
auto_explain Update copyright for 2024 2024-01-03 20:49:05 -05:00
basebackup_to_shell Update copyright for 2024 2024-01-03 20:49:05 -05:00
basic_archive Update copyright for 2024 2024-01-03 20:49:05 -05:00
bloom Update copyright for 2024 2024-01-03 20:49:05 -05:00
bool_plperl Update copyright for 2024 2024-01-03 20:49:05 -05:00
btree_gin Update copyright for 2024 2024-01-03 20:49:05 -05:00
btree_gist Add stratnum GiST support function 2024-01-19 15:42:13 +01:00
citext Update copyright for 2024 2024-01-03 20:49:05 -05:00
cube Update copyright for 2024 2024-01-03 20:49:05 -05:00
dblink Make dblink interruptible, via new libpqsrv APIs. 2024-01-08 11:39:56 -08:00
dict_int Update copyright for 2024 2024-01-03 20:49:05 -05:00
dict_xsyn Update copyright for 2024 2024-01-03 20:49:05 -05:00
earthdistance Update copyright for 2024 2024-01-03 20:49:05 -05:00
file_fdw Update copyright for 2024 2024-01-03 20:49:05 -05:00
fuzzystrmatch Update copyright for 2024 2024-01-03 20:49:05 -05:00
hstore Update copyright for 2024 2024-01-03 20:49:05 -05:00
hstore_plperl Update copyright for 2024 2024-01-03 20:49:05 -05:00
hstore_plpython Update copyright for 2024 2024-01-03 20:49:05 -05:00
intagg Update copyright for 2024 2024-01-03 20:49:05 -05:00
intarray Fix integer-overflow problem in intarray's g_int_decompress(). 2024-01-07 15:19:50 -05:00
isn Update copyright for 2024 2024-01-03 20:49:05 -05:00
jsonb_plperl Update copyright for 2024 2024-01-03 20:49:05 -05:00
jsonb_plpython Update copyright for 2024 2024-01-03 20:49:05 -05:00
lo Update copyright for 2024 2024-01-03 20:49:05 -05:00
ltree Update copyright for 2024 2024-01-03 20:49:05 -05:00
ltree_plpython Update copyright for 2024 2024-01-03 20:49:05 -05:00
oid2name Update copyright for 2024 2024-01-03 20:49:05 -05:00
pageinspect Update copyright for 2024 2024-01-03 20:49:05 -05:00
passwordcheck Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_buffercache Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_freespacemap Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_prewarm Teach autoprewarm to use the dynamic shared memory registry. 2024-01-19 14:43:59 -06:00
pg_stat_statements Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_surgery Error message capitalisation 2024-01-18 09:35:12 +01:00
pg_trgm Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_visibility Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_walinspect Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgcrypto Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgrowlocks Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgstattuple Update copyright for 2024 2024-01-03 20:49:05 -05:00
postgres_fdw Add better handling of redundant IS [NOT] NULL quals 2024-01-23 18:09:18 +13:00
seg seg: Add test "security" in meson.build 2024-01-18 10:12:44 +09:00
sepgsql Update copyright for 2024 2024-01-03 20:49:05 -05:00
spi Update copyright for 2024 2024-01-03 20:49:05 -05:00
sslinfo Update copyright for 2024 2024-01-03 20:49:05 -05:00
start-scripts Remove gratuitous references to postmaster program 2023-01-26 10:48:32 +01:00
tablefunc Update copyright for 2024 2024-01-03 20:49:05 -05:00
tcn Update copyright for 2024 2024-01-03 20:49:05 -05:00
test_decoding Update copyright for 2024 2024-01-03 20:49:05 -05:00
tsm_system_rows Update copyright for 2024 2024-01-03 20:49:05 -05:00
tsm_system_time Update copyright for 2024 2024-01-03 20:49:05 -05:00
unaccent Update copyright for 2024 2024-01-03 20:49:05 -05:00
uuid-ossp Update copyright for 2024 2024-01-03 20:49:05 -05:00
vacuumlo Update copyright for 2024 2024-01-03 20:49:05 -05:00
xml2 Add support for parsing of large XML data (>= 10MB) 2024-01-17 14:03:55 +09:00
Makefile Remove the "snapshot too old" feature. 2023-09-05 19:53:43 +12:00
README Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00
contrib-global.mk Respect TEMP_CONFIG when pg_regress_check and friends are called 2016-02-27 12:28:21 -05:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00

README

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.