postgresql/src/backend
Tom Lane 50ee1c7462 Avoid searching for the target catcache in CatalogCacheIdInvalidate.
A test case provided by Mathieu Fenniak shows that the initial search for
the target catcache in CatalogCacheIdInvalidate consumes a very significant
amount of overhead in cases where cache invalidation is triggered but has
little useful work to do.  There is no good reason for that search to exist
at all, as the index array maintained by syscache.c allows direct lookup of
the catcache from its ID.  We just need a frontend function in syscache.c,
matching the division of labor for most other cache-accessing operations.

While there's more that can be done in this area, this patch alone reduces
the runtime of Mathieu's example by 2X.  We can hope that it offers some
useful benefit in other cases too, although usually cache invalidation
overhead is not such a striking fraction of the total runtime.

Back-patch to 9.4 where logical decoding was introduced.  It might be
worth going further back, but presently the only case we know of where
cache invalidation is really a significant burden is in logical decoding.
Also, older branches have fewer catcaches, reducing the possible benefit.

(Note: although this nominally changes catcache's API, we have always
documented CatalogCacheIdInvalidate as a private function, so I would
have little sympathy for an external module calling it directly.  So
backpatching should be fine.)

Discussion: https://postgr.es/m/CAHoiPjzea6N0zuCi=+f9v_j94nfsy6y8SU7-=bp4=7qw6_i=Rg@mail.gmail.com
2017-05-12 18:17:29 -04:00
..
access Standardize "WAL location" terminology 2017-05-12 13:51:27 -04:00
bootstrap Use one transaction while reading postgres.bki, not one per line. 2017-04-14 17:51:25 -04:00
catalog Fix dependencies for extended statistics objects. 2017-05-12 16:26:31 -04:00
commands Fix dependencies for extended statistics objects. 2017-05-12 16:26:31 -04:00
executor Fix typos in comments. 2017-05-09 23:40:08 -04:00
foreign Abstract logic to allow for multiple kinds of child rels. 2017-04-03 22:41:31 -04:00
lib Revert "Permit dump/reload of not-too-large >1GB tuples" 2017-05-10 18:41:27 -03:00
libpq Remove support for password_encryption='off' / 'plain'. 2017-05-08 11:26:07 +03:00
main Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
nodes Change CREATE STATISTICS syntax 2017-05-12 14:59:35 -03:00
optimizer Reduce semijoins with unique inner relations to plain inner joins. 2017-05-01 14:53:42 -04:00
parser Change CREATE STATISTICS syntax 2017-05-12 14:59:35 -03:00
po
port Provide a way to control SysV shmem attach address in EXEC_BACKEND builds. 2017-04-15 17:27:38 -04:00
postmaster Replace "transaction log" with "write-ahead log" 2017-05-12 11:52:43 -04:00
regex Fix regexport.c to behave sanely with lookaround constraints. 2017-04-13 17:18:35 -04:00
replication Standardize "WAL location" terminology 2017-05-12 13:51:27 -04:00
rewrite RLS: Fix ALL vs. SELECT+UPDATE policy usage 2017-05-06 21:46:35 -04:00
snowball Add ICU_FLAGS to one more place 2017-03-23 16:53:10 -04:00
statistics extstats: change output functions to emit valid JSON 2017-05-02 18:49:32 -03:00
storage Cope with glibc too old to have epoll_create1(). 2017-04-27 17:13:53 -04:00
tcop Improve castNode notation by introducing list-extraction-specific variants. 2017-04-10 13:51:53 -04:00
tsearch Full Text Search support for json and jsonb 2017-03-31 14:26:03 -04:00
utils Avoid searching for the target catcache in CatalogCacheIdInvalidate. 2017-05-12 18:17:29 -04:00
.gitignore
common.mk ICU support 2017-03-23 15:28:48 -04:00
Makefile Implement multivariate n-distinct coefficients 2017-03-24 14:06:10 -03:00
nls.mk