1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Revert "Avoid the creation of the free space map for small heap relations".

This feature was using a process local map to track the first few blocks
in the relation.  The map was reset each time we get the block with enough
freespace.  It was discussed that it would be better to track this map on
a per-relation basis in relcache and then invalidate the same whenever
vacuum frees up some space in the page or when FSM is created.  The new
design would be better both in terms of API design and performance.

List of commits reverted, in reverse chronological order:

06c8a5090e  Improve code comments in b0eaa4c51b.
13e8643bfc  During pg_upgrade, conditionally skip transfer of FSMs.
6f918159a9  Add more tests for FSM.
9c32e4c350  Clear the local map when not used.
29d108cdec  Update the documentation for FSM behavior..
08ecdfe7e5  Make FSM test portable.
b0eaa4c51b  Avoid creation of the free space map for small heap relations.

Discussion: https://postgr.es/m/20190416180452.3pm6uegx54iitbt5@alap3.anarazel.de
This commit is contained in:
Amit Kapila
2019-05-07 09:30:24 +05:30
parent af82f95abb
commit 7db0cde6b5
23 changed files with 107 additions and 686 deletions

View File

@@ -61,8 +61,6 @@
The values stored in the free space map are not exact. They're rounded
to precision of 1/256th of <symbol>BLCKSZ</symbol> (32 bytes with default <symbol>BLCKSZ</symbol>), and
they're not kept fully up-to-date as tuples are inserted and updated.
In addition, small tables don't have a free space map, so these functions
will return zero even if free space is available.
</para>
<para>

View File

@@ -527,9 +527,7 @@ approx_free_percent | 2.09
bit set, then it is assumed to contain no dead tuples). For such
pages, it derives the free space value from the free space map, and
assumes that the rest of the space on the page is taken up by live
tuples. Small tables don't have a free space map, so in that case
this function will report zero free space, likewise inflating the
approximate tuple length.
tuples.
</para>
<para>

View File

@@ -812,13 +812,6 @@ psql --username=postgres --file=script.sql postgres
is down.
</para>
<para>
In <productname>PostgreSQL</productname> 12 and later small tables by
default don't have a free space map, as a space optimization. If you are
upgrading a pre-12 cluster, the free space maps of small tables will
likewise not be transferred to the new cluster.
</para>
</refsect1>
<refsect1>

View File

@@ -598,13 +598,12 @@ tuple would otherwise be too big.
<indexterm><primary>FSM</primary><see>Free Space Map</see></indexterm>
<para>
Each heap relation, unless it is very small, and each index relation, except
for hash indexes, has a Free Space Map (FSM) to keep track of available
space in the relation. It's stored alongside the main relation data in a
separate relation fork, named after the filenode number of the relation, plus
a <literal>_fsm</literal> suffix. For example, if the filenode of a relation
is 12345, the FSM is stored in a file called <filename>12345_fsm</filename>,
in the same directory as the main relation file.
Each heap and index relation, except for hash indexes, has a Free Space Map
(FSM) to keep track of available space in the relation. It's stored
alongside the main relation data in a separate relation fork, named after the
filenode number of the relation, plus a <literal>_fsm</literal> suffix. For example,
if the filenode of a relation is 12345, the FSM is stored in a file called
<filename>12345_fsm</filename>, in the same directory as the main relation file.
</para>
<para>