postgresql/src/include
Tom Lane 8ec5429e2f Reduce "X = X" to "X IS NOT NULL", if it's easy to do so.
If the operator is a strict btree equality operator, and X isn't volatile,
then the clause must yield true for any non-null value of X, or null if X
is null.  At top level of a WHERE clause, we can ignore the distinction
between false and null results, so it's valid to simplify the clause to
"X IS NOT NULL".  This is a useful improvement mainly because we'll get
a far better selectivity estimate in most cases.

Because such cases seldom arise in well-written queries, it is unappetizing
to expend a lot of planner cycles looking for them ... but it turns out
that there's a place we can shoehorn this in practically for free, because
equivclass.c already has to detect and reject candidate equivalences of the
form X = X.  That doesn't catch every place that it would be valid to
simplify to X IS NOT NULL, but it catches the typical case.  Working harder
doesn't seem justified.

Patch by me, reviewed by Petr Jelinek

Discussion: https://postgr.es/m/CAMjNa7cC4X9YR-vAJS-jSYCajhRDvJQnN7m2sLH1wLh-_Z2bsw@mail.gmail.com
2017-10-08 12:23:32 -04:00
..
access Fix traversal of half-frozen update chains 2017-10-06 17:20:01 +02:00
bootstrap Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catalog Copy information from the relcache instead of pointing to it. 2017-10-06 15:28:07 -04:00
commands Allow multiple tables to be specified in one VACUUM or ANALYZE command. 2017-10-03 18:53:44 -04:00
common Increase SCRAM salt length 2017-08-24 14:04:28 -04:00
datatype Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
executor Fix crash when logical decoding is invoked from a PL function. 2017-10-06 19:18:58 -04:00
fe_utils Provide a test for variable existence in psql 2017-09-21 19:02:23 -04:00
foreign Basic partition-wise join functionality. 2017-10-06 11:11:10 -04:00
lib Remove pre-order and post-order traversal logic for red-black trees. 2017-09-10 13:19:11 -04:00
libpq Allow custom search filters to be configured for LDAP auth 2017-09-12 09:49:04 -04:00
mb Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
nodes Basic partition-wise join functionality. 2017-10-06 11:11:10 -04:00
optimizer Reduce "X = X" to "X IS NOT NULL", if it's easy to do so. 2017-10-08 12:23:32 -04:00
parser Support arrays over domains. 2017-09-30 13:40:56 -04:00
port Remove redundant stdint.h include. 2017-10-01 15:24:58 -07:00
portability Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postmaster Add background worker type 2017-09-29 11:08:24 -04:00
regex Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
replication Fix race condition with unprotected use of a latch pointer variable. 2017-10-03 14:00:56 -04:00
rewrite Teach map_partition_varattnos to handle whole-row expressions. 2017-08-03 11:21:29 -04:00
snowball Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
statistics Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
storage Refactor new file permission handling 2017-09-23 10:16:18 -04:00
tcop Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
tsearch Assume wcstombs(), towlower(), and sibling functions are always present. 2017-09-22 11:00:58 -04:00
utils Msvc doesn't know UINT16_MAX, replace with PG_UINT16_MAX. 2017-10-04 10:01:02 -07:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Assume wcstombs(), towlower(), and sibling functions are always present. 2017-09-22 11:00:58 -04:00
fmgr.h Introduce 64-bit hash functions with a 64-bit seed. 2017-08-31 22:21:21 -04:00
funcapi.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
getaddrinfo.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
getopt_long.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
Makefile Add statistics subdirectory to Makefile. 2017-06-08 11:29:50 -04:00
miscadmin.h Remove replacement selection sort. 2017-09-29 10:25:44 -04:00
pg_config.h.in Extend & revamp pg_bswap.h infrastructure. 2017-09-29 17:24:39 -07:00
pg_config.h.win32 Extend & revamp pg_bswap.h infrastructure. 2017-09-29 17:24:39 -07:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix s/intidb/initdb/ typo. 2017-09-22 11:35:26 -07:00
pg_getopt.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_trace.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pgstat.h Avoid use of non-portable strnlen() in pgstat_clip_activity(). 2017-09-19 14:25:47 -07:00
pgtar.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
pgtime.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
port.h Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
postgres.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
rusagestub.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
windowapi.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00