postgresql/contrib/bloom
Heikki Linnakangas 6bc1fd4e60 Use the buffer cache when initializing an unlogged index.
Some of the ambuildempty functions used smgrwrite() directly, followed
by smgrimmedsync(). A few small problems with that:

Firstly, one is supposed to use smgrextend() when extending a
relation, not smgrwrite(). It doesn't make much difference in
production builds. smgrextend() updates the relation size cache, so
you miss that, but that's harmless because we never use the cached
relation size of an init fork. But if you compile with
CHECK_WRITE_VS_EXTEND, you get an assertion failure.

Secondly, the smgrwrite() calls were performed before WAL-logging, so
the page image written to disk had 0/0 as the LSN, not the LSN of the
WAL record. That's also harmless in practice, but seems sloppy.

Thirdly, it's better to use the buffer cache, because then you don't
need to smgrimmedsync() the relation to disk, which adds latency.
Bypassing the cache makes sense for bulk operations like index
creation, but not when you're just initializing an empty index.
Creation of unlogged tables is hardly performance bottleneck in any
real world applications, but nevertheless.

Backpatch to v16, but no further. These issues should be harmless in
practice, so better to not rock the boat in older branches.

Reviewed-by: Robert Haas
Discussion: https://www.postgresql.org/message-id/6e5bbc08-cdfc-b2b3-9e23-1a914b9850a9@iki.fi
2023-08-23 17:23:18 +03:00
..
expected Fix failure with lock mode used for custom relation options 2019-09-25 10:07:23 +09:00
sql Fix failure with lock mode used for custom relation options 2019-09-25 10:07:23 +09:00
t Update copyright for 2023 2023-01-02 15:00:37 -05:00
.gitignore Bloom index contrib module 2016-04-01 16:42:24 +03:00
Makefile Re-enable contrib/bloom's TAP tests. 2021-09-27 18:48:01 -04:00
blcost.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
blinsert.c Use the buffer cache when initializing an unlogged index. 2023-08-23 17:23:18 +03:00
bloom--1.0.sql Minor fixes in contrib installation scripts. 2016-06-14 10:47:06 -04:00
bloom.control Bloom index contrib module 2016-04-01 16:42:24 +03:00
bloom.h Use the buffer cache when initializing an unlogged index. 2023-08-23 17:23:18 +03:00
blscan.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
blutils.c Use the buffer cache when initializing an unlogged index. 2023-08-23 17:23:18 +03:00
blvacuum.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
blvalidate.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00