postgresql/src/include
Tom Lane 39df0f150c Allow planner to use expression-index stats for function calls in WHERE.
Previously, a function call appearing at the top level of WHERE had a
hard-wired selectivity estimate of 0.3333333, a kludge conveniently dated
in the source code itself to July 1992.  The expectation at the time was
that somebody would soon implement estimator support functions analogous
to those for operators; but no such code has appeared, nor does it seem
likely to in the near future.  We do have an alternative solution though,
at least for immutable functions on single relations: creating an
expression index on the function call will allow ANALYZE to gather stats
about the function's selectivity.  But the code in clause_selectivity()
failed to make use of such data even if it exists.

Refactor so that that will happen.  I chose to make it try this technique
for any clause type for which clause_selectivity() doesn't have a special
case, not just functions.  To avoid adding unnecessary overhead in the
common case where we don't learn anything new, make selfuncs.c provide an
API that hooks directly to examine_variable() and then var_eq_const(),
rather than the previous coding which laboriously constructed an OpExpr
only so that it could be expensively deconstructed again.

I preserved the behavior that the default estimate for a function call
is 0.3333333.  (For any other expression node type, it's 0.5, as before.)
I had originally thought to make the default be 0.5 across the board, but
changing a default estimate that's survived for twenty-three years seems
like something not to do without a lot more testing than I care to put
into it right now.

Per a complaint from Jehan-Guillaume de Rorthais.  Back-patch into 9.5,
but not further, at least for the moment.
2015-09-24 18:35:46 -04:00
..
access Allow autoanalyze to add pages deleted from pending list to FSM 2015-09-23 15:33:51 +03:00
bootstrap pgindent run for 9.5 2015-05-23 21:35:49 -04:00
catalog Determine whether it's safe to attempt a parallel plan for a query. 2015-09-16 15:38:47 -04:00
commands Allow per-tablespace effective_io_concurrency 2015-09-08 12:51:42 -03:00
common pgindent run for 9.5 2015-05-23 21:35:49 -04:00
datatype Define integer limits independently from the system definitions. 2015-04-02 17:43:35 +02:00
executor Glue layer to connect the executor to the shm_mq mechanism. 2015-09-18 21:56:58 -04:00
foreign Add support for doing late row locking in FDWs. 2015-05-12 14:10:17 -04:00
lib Avoid use of float arithmetic in bipartite_match.c. 2015-08-23 13:02:18 -04:00
libpq Actually, it's not that hard to merge the Windows pqsignal code ... 2015-08-31 15:52:56 -04:00
mb Teach UtfToLocal/LocalToUtf to support algorithmic encoding conversions. 2015-05-14 22:27:12 -04:00
nodes Add new function planstate_tree_walker. 2015-09-17 11:27:06 -04:00
optimizer Determine whether it's safe to attempt a parallel plan for a query. 2015-09-16 15:38:47 -04:00
parser Determine whether it's safe to attempt a parallel plan for a query. 2015-09-16 15:38:47 -04:00
port Allow icc to use the same atomics infrastructure as gcc. 2015-08-31 16:30:12 -04:00
portability Use mmap MAP_NOSYNC option to limit shared memory writes 2015-03-21 22:06:19 -04:00
postmaster pgindent run for 9.5 2015-05-23 21:35:49 -04:00
regex Fix low-probability memory leak in regex execution. 2015-09-18 13:55:17 -04:00
replication Don't include rel.h when relcache.h is sufficient 2015-08-11 13:03:14 -03:00
rewrite RLS refactoring 2015-09-15 15:49:31 -04:00
snowball Update copyright for 2015 2015-01-06 11:43:47 -05:00
storage Glue layer to connect the executor to the shm_mq mechanism. 2015-09-18 21:56:58 -04:00
tcop Glue layer to connect the executor to the shm_mq mechanism. 2015-09-18 21:56:58 -04:00
tsearch Fix statically allocated struct with FLEXIBLE_ARRAY_MEMBER member. 2015-02-20 17:50:18 -05:00
utils Allow planner to use expression-index stats for function calls in WHERE. 2015-09-24 18:35:46 -04: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 Remove support for Unix systems without the POSIX signal APIs. 2015-08-31 12:56:10 -04:00
fmgr.h Fix comment in fmgr.h to refer to actual function used. 2015-06-15 23:21:03 -04:00
funcapi.h pgindent run for 9.5 2015-05-23 21:35:49 -04:00
getaddrinfo.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
getopt_long.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
Makefile Install lwlocknames.h even in vpath builds. 2015-09-11 16:45:41 -04:00
miscadmin.h Remove the SECURITY_ROW_LEVEL_DISABLED security context bit. 2015-09-20 20:47:17 -04:00
pg_config.h.in Remove support for Unix systems without the POSIX signal APIs. 2015-08-31 12:56:10 -04:00
pg_config.h.win32 Remove support for Unix systems without the POSIX signal APIs. 2015-08-31 12:56:10 -04: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 Define integer limits independently from the system definitions. 2015-04-02 17:43:35 +02:00
pg_getopt.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
pg_trace.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
pgstat.h pgindent run for 9.5 2015-05-23 21:35:49 -04:00
pgtar.h Error when creating names too long for tar format 2015-02-24 13:41:07 -05:00
pgtime.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
port.h Redesign tablesample method API, and do extensive code review. 2015-07-25 14:39:00 -04:00
postgres.h Support "expanded" objects, particularly arrays, for better performance. 2015-05-14 12:08:49 -04:00
postgres_ext.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
postgres_fe.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
rusagestub.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
windowapi.h Update copyright for 2015 2015-01-06 11:43:47 -05:00