postgresql/src/include/utils
Tom Lane a17da19ed9 Invent a "one-shot" variant of CachedPlans for better performance.
SPI_execute() and related functions create a CachedPlan, execute it once,
and immediately discard it, so that the functionality offered by
plancache.c is of no value in this code path.  And performance measurements
show that the extra data copying and invalidation checking done by
plancache.c slows down simple queries by 10% or more compared to 9.1.
However, enough of the SPI code is shared with functions that do need plan
caching that it seems impractical to bypass plancache.c altogether.
Instead, let's invent a variant version of cached plans that preserves
99% of the API but doesn't offer any of the actual functionality, nor the
overhead.  This puts SPI_execute() performance back on par, or maybe even
slightly better, than it was before.  This change should resolve recent
complaints of performance degradation from Dong Ye, Pavel Stehule, and
others.

By avoiding data copying, this change also reduces the amount of memory
needed to execute many-statement SPI_execute() strings, as for instance in
a recent complaint from Tomas Vondra.

An additional benefit of this change is that multi-statement SPI_execute()
query strings are now processed fully serially, that is we complete
execution of earlier statements before running parse analysis and planning
on following ones.  This eliminates a long-standing POLA violation, in that
DDL that affects the behavior of a later statement will now behave as
expected.

Back-patch to 9.2, since this was a performance regression compared to 9.1.
(In 9.2, place the added struct fields so as to avoid changing the offsets
of existing fields.)

Heikki Linnakangas and Tom Lane
2013-01-04 17:42:25 -05:00
..
.gitignore Avoid maintaining three separate copies of the error codes list. 2011-02-03 22:32:49 -05:00
acl.h Improve reporting of permission errors for array types 2012-06-15 23:03:50 +03:00
array.h Collect and use element-frequency statistics for arrays. 2012-03-03 20:20:57 -05:00
ascii.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
attoptcache.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
builtins.h Back-patch fix for extraction of fixed prefixes from regular expressions. 2012-07-10 18:00:39 -04:00
bytea.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
cash.h Add casts from int4 and int8 to numeric. 2011-04-05 09:35:43 -04:00
catcache.h Expose an API for calculating catcache hash values. 2012-03-07 14:51:13 -05:00
combocid.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
date.h Add transform functions for various temporal typmod coercisions. 2012-02-08 09:33:37 -05:00
datetime.h Improve EncodeDateTime and EncodeTimeOnly APIs 2012-03-14 23:03:34 +02:00
datum.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
dynahash.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
dynamic_loader.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
elog.h Mark ReThrowError() with attribute noreturn 2012-04-30 20:23:41 +03:00
fmgrtab.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
formatting.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geo_decls.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
guc.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
guc_tables.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
help_config.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
hsearch.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
inet.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
int8.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
inval.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
json.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
logtape.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
lsyscache.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
memutils.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
nabstime.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
numeric.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
palloc.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
pg_crc.h Add const qualifiers where they are accidentally cast away 2012-02-28 12:42:08 +02:00
pg_crc_tables.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
pg_locale.h Replace empty locale name with implied value in CREATE DATABASE and initdb. 2012-03-25 21:47:22 -04:00
pg_lzcompress.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
pg_rusage.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
plancache.h Invent a "one-shot" variant of CachedPlans for better performance. 2013-01-04 17:42:25 -05:00
portal.h Run a portal's cleanup hook immediately when pushing it to FAILED state. 2012-02-15 16:19:01 -05:00
ps_status.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
rangetypes.h Refactor the way code is shared between some range type functions. 2012-07-18 23:15:08 +03:00
rbtree.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
rel.h Fix failure to ignore leftover temp tables after a server crash. 2012-12-17 20:15:39 -05:00
relcache.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
relmapper.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
reltrigger.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
resowner.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
selfuncs.h Refactor pattern_fixed_prefix() to avoid dealing in incomplete patterns. 2012-07-09 23:23:02 -04:00
snapmgr.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
snapshot.h Slightly reorganize struct SnapshotData. 2012-01-06 22:56:00 -05:00
sortsupport.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
spccache.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
syscache.h Expose an API for calculating catcache hash values. 2012-03-07 14:51:13 -05:00
timestamp.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
tqual.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
tuplesort.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
tuplestore.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
typcache.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
tzparser.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
uuid.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
varbit.h Add a transform function for varbit typmod coercisions. 2012-02-07 12:42:50 -05:00
xml.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00