Re: WIP: Avoid creation of the free space map for small tables

From: John Naylor <jcnaylor(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: Avoid creation of the free space map for small tables
Date: 2018-10-14 16:29:28
Message-ID: CAJVSVGUJUAEs7=02BrsnHwK+hyFh5gm174fJ2eXUJ6+3SXmrUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

> On 10/13/18, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>> I think you have found a good way to avoid creating FSM, but can't we
>> use some simpler technique like if the FSM fork for a relation doesn't
>> exist, then check the heapblk number for which we try to update the
>> FSM and if it is lesser than HEAP_FSM_EXTENSION_THRESHOLD, then avoid
>> creating the FSM.

>> I think it would be better if we can find a common way to avoid
>> creating FSM both during DO and REDO time. It might be possible if
>> somethin like what I have said above is feasible.

I've attached v4, which implements the REDO case, and as closely as
possible to the DO case. I've created a new function to guard against
creation of the FSM, which is called by RecordPageWithFreeSpace() and
RecordAndGetPageWithFreeSpace(). Since XLogRecordPageWithFreeSpace()
takes a relfilenode and not a relation, I had to reimplement that
separately, but the logic is basically the same. It works under
streaming replication.

I've also attached a couple SQL scripts which, when the aforementioned
DEBUG1 calls are enabled, show what the heap insert code is doing for
different scenarios. Make check-world passes.

-John Naylor

Attachment Content-Type Size
v4-0001-Avoid-creation-of-the-free-space-map-for-small-ta.patch text/x-patch 17.5 KB
test-fsm-first-10-blocks.sql application/sql 839 bytes
test-nofsm-first-block.sql application/sql 901 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-10-14 17:42:40 Re: pgsql: Avoid duplicate XIDs at recovery when building initial snapshot
Previous Message Tom Lane 2018-10-14 16:20:55 Re: rowcount estimate varies WRT partitionwise_join