Thread: pgsql: Add pages deleted from pending list to FSM

pgsql: Add pages deleted from pending list to FSM

From
Teodor Sigaev
Date:
Add pages deleted from pending list to FSM

Add pages deleted from GIN's pending list during cleanup to free space map
immediately. Clean up process could be initiated by ordinary insert but adding
page to FSM might occur only at vacuum. On some workload like never-vacuumed
insert-only tables it could cause a huge bloat.

Jeff Janes <jeff.janes@gmail.com>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e95680832854cf300e64c10de9cc2f586df558e8

Modified Files
--------------
src/backend/access/gin/ginfast.c |   23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)


Re: pgsql: Add pages deleted from pending list to FSM

From
Fujii Masao
Date:
On Mon, Sep 7, 2015 at 10:29 PM, Teodor Sigaev <teodor@sigaev.ru> wrote:
> Add pages deleted from pending list to FSM
>
> Add pages deleted from GIN's pending list during cleanup to free space map
> immediately. Clean up process could be initiated by ordinary insert but adding
> page to FSM might occur only at vacuum. On some workload like never-vacuumed
> insert-only tables it could cause a huge bloat.

+    /*
+     * As pending list pages can have a high churn rate, it is
+     * desirable to recycle them immediately to the FreeSpace Map when
+     * ordinary backends clean the list.
+     */
+    if (fsm_vac && !vac_delay)
+        IndexFreeSpaceMapVacuum(index);

So autoanalyze still doesn't call IndexFreeSpaceMapVacuum().
That is, only backend can clean the list in INSERT-only workload.
I don't think that this is desirable. Because the backend will
periodically take a big performance penalty.

So I'm thinking that even autoanalyze should call IndexFreeSpaceMapVacuum()
to clean the list in a background, in order to avoid such spikes in
INSERT response time. Thought?

+        for (i = 0; i < data.ndeleted; i++)
+            RecordFreeIndexPage(index, freespace[i]);

ginvacuumcleanup calls RecordFreeIndexPage() twice for the same block.
One is in shiftList(), and another is in ginvacuumcleanup().
I'm just wondering if this affects the VACUUM performance especially
when the pending list size is set to very big.

Regards,

--
Fujii Masao