Thread: pgsql: Speed up truncation of temporary relations.

pgsql: Speed up truncation of temporary relations.

From
Fujii Masao
Date:
Speed up truncation of temporary relations.

Previously, truncating a temporary relation required scanning the entire
local buffer pool once per relation fork to invalidate buffers. This could
be slow, especially with a large local buffers, as the scan was repeated
multiple times.

A similar issue with regular tables (shared buffers) was addressed in
commit 6d05086c0a7 by scanning the buffer pool only once for all forks.

This commit applies the same optimization to temporary relations,
improving truncation performance.

Author: Daniil Davydov <3danissimo@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Maxim Orlov <orlovmg@gmail.com>
Discussion: https://postgr.es/m/CAJDiXggNqsJOH7C5co4jA8nDk8vw-=sokyh5s1_TENWnC6Ofcg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/78ebda66bf2683d42b853660757aaf16268ee3b7

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c   |  8 +++-----
src/backend/storage/buffer/localbuf.c | 21 ++++++++++++++-------
src/include/storage/buf_internals.h   |  4 ++--
3 files changed, 19 insertions(+), 14 deletions(-)