postgresql/contrib/pageinspect/sql
Amit Kapila ac88d2962a Avoid creation of the free space map for small heap relations.
Previously, all heaps had FSMs. For very small tables, this means that the
FSM took up more space than the heap did. This is wasteful, so now we
refrain from creating the FSM for heaps with 4 pages or fewer. If the last
known target block has insufficient space, we still try to insert into some
other page before giving up and extending the relation, since doing
otherwise leads to table bloat. Testing showed that trying every page
penalized performance slightly, so we compromise and try every other page.
This way, we visit at most two pages. Any pages with wasted free space
become visible at next relation extension, so we still control table bloat.
As a bonus, directly attempting one or two pages can even be faster than
consulting the FSM would have been.

Once the FSM is created for a heap we don't remove it even if somebody
deletes all the rows from the corresponding relation.  We don't think it is
a useful optimization as it is quite likely that relation will again grow
to the same size.

Author: John Naylor with design inputs and some code contribution by Amit Kapila
Reviewed-by: Amit Kapila
Tested-by: Mithun C Y
Discussion: https://www.postgresql.org/message-id/CAJVSVGWvB13PzpbLEecFuGFc5V2fsO736BsdTakPiPAcdMM5tQ@mail.gmail.com
2019-01-28 08:14:06 +05:30
..
brin.sql pageinspect: Add tests 2016-11-01 14:02:16 -04:00
btree.sql pageinspect: Add bt_page_items function with bytea argument 2017-04-04 23:52:55 -04:00
gin.sql Fix gin_leafpage_items(). 2016-11-04 12:11:54 -04:00
hash.sql pageinspect: Remove platform-dependent values from hash tests. 2017-02-03 11:06:41 -05:00
page.sql Avoid creation of the free space map for small heap relations. 2019-01-28 08:14:06 +05:30