pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid creation of the free space map for small heap relations, t
Date: Mon, 04 Feb 2019 02:22:49 +0000
Message-ID: <E1gqTuL-0004Wj-U7@gemulon.postgresql.org> (raw)

Avoid creation of the free space map for small heap relations, take 2.

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, Amit Kapila
Reviewed-by: Amit Kapila
Tested-by: Mithun C Y
Discussion: https://www.postgresql.org/message-id/CAJVSVGWvB13PzpbLEecFuGFc5V2fsO736BsdTakPiPAcdMM5tQ@mail.gmail...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b0eaa4c51bbff3e3c600b11e5d104d6feb9ca77f

Modified Files
--------------
contrib/pageinspect/expected/page.out     |  77 ++++----
contrib/pageinspect/sql/page.sql          |  33 ++--
doc/src/sgml/storage.sgml                 |  13 +-
src/backend/access/brin/brin.c            |   2 +-
src/backend/access/brin/brin_pageops.c    |  10 +-
src/backend/access/heap/hio.c             |  45 +++--
src/backend/access/heap/vacuumlazy.c      |  17 +-
src/backend/access/transam/xact.c         |  14 ++
src/backend/storage/freespace/README      |  38 +++-
src/backend/storage/freespace/freespace.c | 285 +++++++++++++++++++++++++++++-
src/backend/storage/freespace/indexfsm.c  |   6 +-
src/include/storage/freespace.h           |   9 +-
src/test/regress/expected/fsm.out         |  48 +++++
src/test/regress/parallel_schedule        |   6 +
src/test/regress/serial_schedule          |   1 +
src/test/regress/sql/fsm.sql              |  41 +++++
16 files changed, 543 insertions(+), 102 deletions(-)



view thread (29+ messages)  latest in thread

Message-ID: <E1gqTuL-0004Wj-U7@gemulon.postgresql.org>
Permalink:  ../E1gqTuL-0004Wj-U7@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gqTuL-0004Wj-U7@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akapila@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Avoid creation of the free space map for small heap relations, t
  In-Reply-To: <E1gqTuL-0004Wj-U7@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox