postgresql/src/include/utils
Thomas Munro 8cc6016a8c Avoid catalog lookups in RelationAllowsEarlyPruning().
RelationAllowsEarlyPruning() performed a catalog scan, but is used
in two contexts where that was a bad idea:

1.  In heap_page_prune_opt(), which runs very frequently in some large
    scans.  This caused major performance problems in a field report
    that was easy to reproduce.

2.  In TestForOldSnapshot(), which runs while we hold a buffer content
    lock.  It's not clear if this was guaranteed to be free of buffer
    deadlock risk.

The check was introduced in commit 2cc41acd8 and defended against a
real problem: 9.6's hash indexes have no page LSN and so we can't
allow early pruning (ie the snapshot-too-old feature).  We can remove
the check from all later releases though: hash indexes are now logged,
and there is no way to create UNLOGGED indexes on regular logged
tables.

If a future release allows such a combination, it might need to put
a similar check in place, but it'll need some more thought.

Back-patch to 10.

Author: Thomas Munro
Reviewed-by: Tom Lane, who spotted the second problem
Discussion: https://postgr.es/m/CA%2BhUKGKT8oTkp5jw_U4p0S-7UG9zsvtw_M47Y285bER6a2gD%2Bg%40mail.gmail.com
Discussion: https://postgr.es/m/CAA4eK1%2BWy%2BN4eE5zPm765h68LrkWc3Biu_8rzzi%2BOYX4j%2BiHRw%40mail.gmail.com
2019-08-28 16:18:39 +12:00
..
.gitignore Revert "Add gitignore entries for jsonpath_gram.h" 2019-03-23 00:19:34 +01:00
acl.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
aclchk_internal.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
array.h Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType. 2019-06-30 17:34:17 -07:00
arrayaccess.h Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType. 2019-06-30 17:34:17 -07:00
ascii.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
attoptcache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
builtins.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
bytea.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
cash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catcache.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
combocid.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
date.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
datetime.h Remove explicit error handling for obsolete date/time values 2019-06-30 10:27:35 +02:00
datum.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
dsa.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
dynahash.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
elog.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
evtcache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
expandeddatum.h Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType. 2019-06-30 17:34:17 -07:00
expandedrecord.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
float.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
fmgrtab.h Reduce the size of the fmgr_builtin_oid_index[] array. 2019-01-09 15:22:43 -05:00
formatting.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
freepage.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
geo_decls.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
guc.h Revert "Add log_statement_sample_rate parameter" 2019-08-04 23:37:44 +02:00
guc_tables.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
hashutils.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
help_config.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
hsearch.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
index_selfuncs.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
inet.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
int8.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
inval.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
json.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
jsonapi.h Fix more typos and inconsistencies in the tree 2019-06-17 16:13:16 +09:00
jsonb.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
jsonpath.h Support 'q' flag in jsonpath 'like_regex' predicate 2019-06-19 22:41:57 +03:00
logtape.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
lsyscache.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
memdebug.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
memutils.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
numeric.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
palloc.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
partcache.h Move code for managing PartitionDescs into a new file, partdesc.c 2019-02-21 11:45:02 -05:00
pg_crc.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_locale.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_lsn.h Don't call data type input functions in GUC check hooks 2019-06-30 10:27:43 +02:00
pg_rusage.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pidfile.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
plancache.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
portal.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
ps_status.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
queryenvironment.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rangetypes.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
regproc.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
rel.h Avoid catalog lookups in RelationAllowsEarlyPruning(). 2019-08-28 16:18:39 +12:00
relcache.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
relfilenodemap.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
relmapper.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
relptr.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
reltrigger.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
resowner.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
resowner_private.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
rls.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
ruleutils.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
sampling.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
selfuncs.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
sharedtuplestore.h Fix more typos and inconsistencies in the tree 2019-06-17 16:13:16 +09:00
snapmgr.h Avoid catalog lookups in RelationAllowsEarlyPruning(). 2019-08-28 16:18:39 +12:00
snapshot.h Fix double-word typos 2019-06-13 10:03:56 -04:00
sortsupport.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
spccache.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
syscache.h Rework the pg_statistic_ext catalog 2019-06-16 01:20:31 +02:00
timeout.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
timestamp.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
tuplesort.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
tuplestore.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
typcache.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
tzparser.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
uuid.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
varbit.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
varlena.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
xml.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00