pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Avoid looping over all type cache entries in TypeCacheRelCallbac
2+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid looping over all type cache entries in TypeCacheRelCallbac
@ 2024-08-25 00:56  Alexander Korotkov <akorotkov@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Alexander Korotkov @ 2024-08-25 00:56 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid looping over all type cache entries in TypeCacheRelCallback()

Currently when a single relcache entry gets invalidated,
TypeCacheRelCallback() has to loop over all type cache entries to find
appropriate typentry to invalidate.  Unfortunately, using the syscache here
is impossible, because this callback could be called outside a transaction
and this makes impossible catalog lookups.  This is why present commit
introduces RelIdToTypeIdCacheHash to map relation OID to its composite type
OID.

We are keeping RelIdToTypeIdCacheHash entry while corresponding type cache
entry have something to clean.  Therefore, RelIdToTypeIdCacheHash shouldn't
get bloat in the case of temporary tables flood.

Discussion: https://postgr.es/m/5812a6e5-68ae-4d84-9d85-b443176966a1%40sigaev.ru
Author: Teodor Sigaev
Reviewed-by: Aleksander Alekseev, Tom Lane, Michael Paquier, Roman Zharkov
Reviewed-by: Andrei Lepikhov, Pavel Borisov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c14d4acb81348a34497b53a19dce2924cc4f6551

Modified Files
--------------
src/backend/utils/cache/typcache.c | 275 +++++++++++++++++++++++++++++++------
src/tools/pgindent/typedefs.list   |   1 +
2 files changed, 232 insertions(+), 44 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Avoid looping over all type cache entries in TypeCacheRelCallbac
@ 2024-10-24 11:36  Alexander Korotkov <akorotkov@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Alexander Korotkov @ 2024-10-24 11:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid looping over all type cache entries in TypeCacheRelCallback()

Currently, when a single relcache entry gets invalidated,
TypeCacheRelCallback() has to loop over all type cache entries to find
appropriate typentry to invalidate.  Unfortunately, using the syscache here
is impossible, because this callback could be called outside a transaction
and this makes impossible catalog lookups.  This is why present commit
introduces RelIdToTypeIdCacheHash to map relation OID to its composite type
OID.

We are keeping RelIdToTypeIdCacheHash entry while corresponding type cache
entry have something to clean.  Therefore, RelIdToTypeIdCacheHash shouldn't
get bloat in the case of temporary tables flood.

There are many places in lookup_type_cache() where syscache invalidation,
user interruption, or even error could occur.  In order to handle this, we
keep an array of in-progress type cache entries.  In the case of
lookup_type_cache() interruption this array is processed to keep
RelIdToTypeIdCacheHash in a consistent state.

Discussion: https://postgr.es/m/5812a6e5-68ae-4d84-9d85-b443176966a1%40sigaev.ru
Author: Teodor Sigaev
Reviewed-by: Aleksander Alekseev, Tom Lane, Michael Paquier, Roman Zharkov
Reviewed-by: Andrei Lepikhov, Pavel Borisov, Jian He, Alexander Lakhin
Reviewed-by: Artur Zakirov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b85a9d046efdd27775cbe7db9e92aad96aab4ada

Modified Files
--------------
src/backend/access/transam/xact.c                  |  10 +
src/backend/utils/cache/typcache.c                 | 359 ++++++++++++++++++---
src/include/utils/typcache.h                       |   4 +
src/test/modules/Makefile                          |   4 +-
src/test/modules/meson.build                       |   1 +
src/test/modules/typcache/.gitignore               |   4 +
src/test/modules/typcache/Makefile                 |  28 ++
.../typcache/expected/typcache_rel_type_cache.out  |  34 ++
src/test/modules/typcache/meson.build              |  16 +
.../typcache/sql/typcache_rel_type_cache.sql       |  18 ++
src/tools/pgindent/typedefs.list                   |   1 +
11 files changed, 433 insertions(+), 46 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-10-24 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-25 00:56 pgsql: Avoid looping over all type cache entries in TypeCacheRelCallbac Alexander Korotkov <akorotkov@postgresql.org>
2024-10-24 11:36 pgsql: Avoid looping over all type cache entries in TypeCacheRelCallbac Alexander Korotkov <akorotkov@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox