postgresql/src/tools
Andres Freund b8d7f053c5 Faster expression evaluation and targetlist projection.
This replaces the old, recursive tree-walk based evaluation, with
non-recursive, opcode dispatch based, expression evaluation.
Projection is now implemented as part of expression evaluation.

This both leads to significant performance improvements, and makes
future just-in-time compilation of expressions easier.

The speed gains primarily come from:
- non-recursive implementation reduces stack usage / overhead
- simple sub-expressions are implemented with a single jump, without
  function calls
- sharing some state between different sub-expressions
- reduced amount of indirect/hard to predict memory accesses by laying
  out operation metadata sequentially; including the avoidance of
  nearly all of the previously used linked lists
- more code has been moved to expression initialization, avoiding
  constant re-checks at evaluation time

Future just-in-time compilation (JIT) has become easier, as
demonstrated by released patches intended to be merged in a later
release, for primarily two reasons: Firstly, due to a stricter split
between expression initialization and evaluation, less code has to be
handled by the JIT. Secondly, due to the non-recursive nature of the
generated "instructions", less performance-critical code-paths can
easily be shared between interpreted and compiled evaluation.

The new framework allows for significant future optimizations. E.g.:
- basic infrastructure for to later reduce the per executor-startup
  overhead of expression evaluation, by caching state in prepared
  statements.  That'd be helpful in OLTPish scenarios where
  initialization overhead is measurable.
- optimizing the generated "code". A number of proposals for potential
  work has already been made.
- optimizing the interpreter. Similarly a number of proposals have
  been made here too.

The move of logic into the expression initialization step leads to some
backward-incompatible changes:
- Function permission checks are now done during expression
  initialization, whereas previously they were done during
  execution. In edge cases this can lead to errors being raised that
  previously wouldn't have been, e.g. a NULL array being coerced to a
  different array type previously didn't perform checks.
- The set of domain constraints to be checked, is now evaluated once
  during expression initialization, previously it was re-built
  every time a domain check was evaluated. For normal queries this
  doesn't change much, but e.g. for plpgsql functions, which caches
  ExprStates, the old set could stick around longer.  The behavior
  around might still change.

Author: Andres Freund, with significant changes by Tom Lane,
	changes by Heikki Linnakangas
Reviewed-By: Tom Lane, Heikki Linnakangas
Discussion: https://postgr.es/m/20161206034955.bh33paeralxbtluv@alap3.anarazel.de
2017-03-25 14:52:06 -07:00
..
editors emacs: Set indent-tabs-mode in perl-mode 2015-04-12 23:53:23 -04:00
entab pgindent run for 9.4 2014-05-06 12:12:18 -04:00
findoidjoins Fix hard-coded relkind constants in assorted other files. 2017-03-09 23:36:52 -05:00
ifaddrs Clean up test_ifaddrs a bit. 2017-03-07 12:06:07 -05:00
make_diff Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
msvc Remove createlang and droplang 2017-03-23 14:16:45 -04:00
pginclude Use 'use strict' in all Perl programs 2017-01-05 12:34:48 -05:00
pgindent Faster expression evaluation and targetlist projection. 2017-03-25 14:52:06 -07:00
ccsym tools/ccsym: update for modern versions of gcc 2015-01-20 13:02:58 -05:00
check_bison_recursion.pl Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
codelines Fix remaining stray references to CVS. 2010-09-22 19:51:39 -04:00
copyright.pl Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
FAQ2txt Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
find_badmacros Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
find_static Fix omission of -X (--no-psqlrc) in some psql invocations. 2015-12-28 11:46:43 -05:00
find_typedef Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
fix-old-flex-code.pl Dept of second thoughts: rename new perl script. 2017-02-19 16:41:51 -05:00
git_changelog Update git_changelog to know that there's a 9.6 branch. 2016-08-15 15:24:54 -04:00
git-external-diff Add comment to tools/git-external-diff. 2011-03-11 05:06:31 -05:00
make_ctags Mention original ctags option name. 2012-02-24 16:19:18 -05:00
make_etags Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
make_mkid Add another pgdefine path check, and a cvs-git change. 2011-08-26 21:52:35 -04:00
pgtest pgtest: allow passing parameters, e.g. -s/--silent 2013-08-05 19:59:52 -04:00
RELEASE_CHANGES Remove vestigial references to "zic" in favor of "IANA database". 2016-09-04 19:42:08 -04:00
valgrind.supp Copyedit comments and documentation. 2016-04-01 21:53:10 -04:00
version_stamp.pl Use 'use strict' in all Perl programs 2017-01-05 12:34:48 -05:00
win32tzlist.pl Update copyright via script for 2017 2017-01-03 13:48:53 -05:00