postgresql/src/include
Tom Lane baf17ad9df Repair performance regression in information_schema.triggers view.
Commit 32ff26911 introduced use of rank() into the triggers view to
calculate the spec-mandated action_order column.  As written, this
prevents query constraints on the table-name column from being pushed
below the window aggregate step.  That's bad for performance of this
typical usage pattern, since the view now has to be evaluated for all
tables not just the one(s) the user wants to see.  It's also the cause
of some recent buildfarm failures, in which trying to evaluate the view
rows for triggers in process of being dropped resulted in "cache lookup
failed for function NNN" errors.  Those rows aren't of interest to the
test script doing the query, but the filter that would eliminate them
is being applied too late.  None of this happened before the rank()
call was there, so it's a regression compared to v10 and before.

We can improve matters by changing the rank() call so that instead of
partitioning by OIDs, it partitions by nspname and relname, casting
those to sql_identifier so that they match the respective view output
columns exactly.  The planner has enough intelligence to know that
constraints on partitioning columns are safe to push down, so this
eliminates the performance problem and the regression test failure
risk.  We could make the other partitioning columns match view outputs
as well, but it'd be more complicated and the performance benefits
are questionable.

Side note: as this stands, the planner will push down constraints on
event_object_table and trigger_schema, but not on event_object_schema,
because it checks for ressortgroupref matches not expression
equivalence.  That might be worth improving someday, but it's not
necessary to fix the immediate concern.

Back-patch to v11 where the rank() call was added.  Ordinarily we'd not
change information_schema in released branches, but the test failure has
been seen in v12 and presumably could happen in v11 as well, so we need
to do this to keep the buildfarm happy.  The change is harmless so far
as users are concerned.  Some might wish to apply it to existing
installations if performance of this type of query is of concern,
but those who don't are no worse off.

I bumped catversion in HEAD as a pro forma matter (there's no
catalog incompatibility that would really require a re-initdb).
Obviously that can't be done in the back branches.

Discussion: https://postgr.es/m/5891.1587594470@sss.pgh.pa.us
2020-04-24 12:02:36 -04:00
..
access Fix handling of WAL segments ready to be archived during crash recovery 2020-04-24 08:48:28 +09:00
bootstrap Update copyrights for 2020 2020-01-01 12:21:45 -05:00
catalog Repair performance regression in information_schema.triggers view. 2020-04-24 12:02:36 -04:00
commands Comments and doc fixes for commit 40d964ec99. 2020-04-14 08:10:27 +05:30
common Update Unicode data to Unicode 13.0.0 and CLDR 37 2020-04-24 09:52:59 +02:00
datatype Update copyrights for 2020 2020-01-01 12:21:45 -05:00
executor Cosmetic fixups for WAL usage work. 2020-04-13 15:31:16 +05:30
fe_utils Reduce size of backend scanner's tables. 2020-01-13 15:04:31 -05:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit jit: Reference expression step functions via llvmjit_types. 2020-02-06 22:29:14 -08:00
lib Fix collection of typos and grammar mistakes in the tree 2020-04-10 11:18:39 +09:00
libpq Only provide openssl_tls_init_hook if building with openssl 2020-04-17 15:57:19 -04:00
mb Allow Unicode escapes in any server encoding, not only UTF-8. 2020-03-06 14:17:43 -05:00
nodes Add ALTER .. NO DEPENDS ON 2020-04-20 13:42:12 -04:00
optimizer Support FETCH FIRST WITH TIES 2020-04-07 16:22:13 -04:00
parser Revert 0f5ca02f53 2020-04-08 11:37:27 +03:00
partitioning Allow partitionwise joins in more cases. 2020-04-08 10:25:00 +09:00
port Modify various power 2 calculations to use new helper functions 2020-04-08 16:55:03 +12:00
portability Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postmaster Trigger autovacuum based on number of INSERTs 2020-03-28 19:20:12 +13:00
regex Assume that we have <wchar.h>. 2020-02-21 14:30:47 -05:00
replication Also rename 'struct manifest_info'. 2020-04-23 09:47:50 -04:00
rewrite Update copyrights for 2020 2020-01-01 12:21:45 -05:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Use multi-variate MCV lists to estimate ScalarArrayOpExpr 2020-03-14 16:13:00 +01:00
storage Support PrefetchBuffer() in recovery. 2020-04-08 14:56:57 +12:00
tcop Allow the planner-related functions and hook to accept the query string. 2020-03-30 13:51:05 +09:00
tsearch Assume that we have <wchar.h>. 2020-02-21 14:30:47 -05:00
utils Clean up cpluspluscheck violation. 2020-04-21 11:21:15 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Enable Unix-domain sockets support on Windows 2020-03-28 15:01:01 +01:00
fmgr.h Fix minor violations of FunctionCallInvoke usage protocol. 2020-04-21 14:23:53 -04:00
funcapi.h Avoid holding a directory FD open across assorted SRF calls. 2020-03-16 21:05:52 -04:00
getaddrinfo.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
getopt_long.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
miscadmin.h Unify several ways to tracking backend type 2020-03-13 14:01:10 +01:00
pg_config.h.in Enable Unix-domain sockets support on Windows 2020-03-28 15:01:01 +01: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_manual.h Remove ACLDEBUG #define and associated code. 2020-04-23 15:38:04 -04:00
pg_getopt.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_trace.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgstat.h Add wait events for recovery conflicts. 2020-04-03 12:15:56 +09:00
pgtar.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgtime.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
port.h Add -c/--restore-target-wal to pg_rewind 2020-04-01 10:57:03 +09:00
postgres.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
rusagestub.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
windowapi.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00