postgresql/src/include
Tom Lane 1383e2a1a9 Improve FSM management for BRIN indexes.
BRIN indexes like to propagate additions of free space into the upper pages
of their free space maps as soon as the new space is known, even when it's
just on one individual index page.  Previously this required calling
FreeSpaceMapVacuum, which is quite an expensive thing if the map is large.
Use the FreeSpaceMapVacuumRange function recently added by commit c79f6df75
to reduce the amount of work done for this purpose.

Fix a couple of places that neglected to do the upper-page vacuuming at all
after recording new free space.  If the policy is to be that BRIN should do
that, it should do it everywhere.

Do RecordPageWithFreeSpace unconditionally in brin_page_cleanup, and do
FreeSpaceMapVacuum unconditionally in brin_vacuum_scan.  Because of the
FSM's imprecise storage of free space, the old complications here seldom
bought anything, they just slowed things down.  This approach also
provides a predictable path for FSM corruption to be repaired.

Remove premature RecordPageWithFreeSpace call in brin_getinsertbuffer
where it's about to return an extended page to the caller.  The caller
should do that, instead, after it's inserted its new tuple.  Fix the
one caller that forgot to do so.

Simplify logic in brin_doupdate's same-page-update case by postponing
brin_initialize_empty_new_buffer to after the critical section; I see
little point in doing it before.

Avoid repeat calls of RelationGetNumberOfBlocks in brin_vacuum_scan.
Avoid duplicate BufferGetBlockNumber and BufferGetPage calls in
a couple of places where we already had the right values.

Move a BRIN_elog debug logging call out of a critical section; that's
pretty unsafe and I don't think it buys us anything to not wait till
after the critical section.

Move the "*extended = false" step in brin_getinsertbuffer into the
routine's main loop.  There's no actual bug there, since the loop can't
iterate with *extended still true, but it doesn't seem very future-proof
as coded; and it's certainly not documented as a loop invariant.

This is all from follow-on investigation inspired by commit c79f6df75.

Discussion: https://postgr.es/m/5801.1522429460@sss.pgh.pa.us
2018-04-04 14:26:04 -04:00
..
access Improve FSM management for BRIN indexes. 2018-04-04 14:26:04 -04:00
bootstrap Update copyright for 2018 2018-01-02 23:30:12 -05:00
catalog Foreign keys on partitioned tables 2018-04-04 14:02:49 -03:00
commands Foreign keys on partitioned tables 2018-04-04 14:02:49 -03:00
common restrict -> pg_restrict 2018-03-15 10:02:59 -03:00
datatype Update copyright for 2018 2018-01-02 23:30:12 -05:00
executor New files for MERGE 2018-04-03 10:22:21 +01:00
fe_utils Add \if support to pgbench 2018-03-22 17:42:03 +03:00
foreign postgres_fdw: Push down partition-wise aggregation. 2018-04-02 10:51:50 -04:00
jit Fix a boatload of typos in C comments. 2018-04-01 15:01:28 -04:00
lib Fix a boatload of typos in C comments. 2018-04-01 15:01:28 -04:00
libpq Make be-secure-common.c more consistent for future SSL implementations 2018-04-02 11:37:40 -04:00
mb Fix a boatload of typos in C comments. 2018-04-01 15:01:28 -04:00
nodes WITH support in MERGE 2018-04-03 12:13:59 +01:00
optimizer MERGE SQL Command following SQL:2016 2018-04-03 09:28:16 +01:00
parser New files for MERGE 2018-04-03 10:22:21 +01:00
port Use ARMv8 CRC instructions where available. 2018-04-04 12:22:45 +03:00
portability Update copyright for 2018 2018-01-02 23:30:12 -05:00
postmaster Fix more format truncation issues 2018-03-15 11:41:42 -04:00
regex Update copyright for 2018 2018-01-02 23:30:12 -05:00
replication Portability fix for commit 9a895462d. 2018-03-30 20:52:13 -04:00
rewrite MERGE SQL Command following SQL:2016 2018-04-03 09:28:16 +01:00
snowball Update copyright for 2018 2018-01-02 23:30:12 -05:00
statistics Update copyright for 2018 2018-01-02 23:30:12 -05:00
storage Remove UpdateFreeSpaceMap(), use FreeSpaceMapVacuumRange() instead. 2018-03-29 12:22:44 -04:00
tcop PL/pgSQL: Nested CALL with transactions 2018-03-28 13:31:27 -04:00
tsearch Update copyright for 2018 2018-01-02 23:30:12 -05:00
utils Skip full index scan during cleanup of B-tree indexes when possible 2018-04-04 19:29:00 +03:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Fix interaction of Perl and stdbool.h 2018-03-23 10:31:10 -04:00
fmgr.h Add expression compilation support to LLVM JIT provider. 2018-03-22 14:45:59 -07:00
funcapi.h Support INOUT arguments in procedures 2018-03-14 12:07:28 -04:00
getaddrinfo.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
getopt_long.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
Makefile Add statistics subdirectory to Makefile. 2017-06-08 11:29:50 -04:00
miscadmin.h Skip full index scan during cleanup of B-tree indexes when possible 2018-04-04 19:29:00 +03:00
pg_config.h.in Use ARMv8 CRC instructions where available. 2018-04-04 12:22:45 +03:00
pg_config.h.win32 Also fix the descriptions in pg_config.h.win32. 2018-04-04 11:33:39 +03: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_ext.h.win32 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 Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_getopt.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_trace.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgstat.h Support parallel btree index builds. 2018-02-02 13:32:44 -05:00
pgtar.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgtime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
port.h Fix a boatload of typos in C comments. 2018-04-01 15:01:28 -04:00
postgres.h Move the extern declaration for ExceptionalCondition into c.h. 2018-02-14 19:43:33 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rusagestub.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
windowapi.h Update copyright for 2018 2018-01-02 23:30:12 -05:00