Skip site navigation (1) Skip section navigation (2)

Proposed patch to change TOAST compression strategy

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-patches(at)postgreSQL(dot)org
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, "Jan Wieck" <JanWieck(at)Yahoo(dot)com>
Subject: Proposed patch to change TOAST compression strategy
Date: 2008-02-17 18:12:19
Message-ID: 26048.1203271939@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
This proposed patch addresses some issues in TOAST compression strategy that
were discussed last year, but we felt it was too late in the 8.3 cycle to
change the code immediately.  See these threads for background:
http://archives.postgresql.org/pgsql-hackers/2007-08/msg00082.php
http://archives.postgresql.org/pgsql-general/2007-08/msg01129.php

Specifically, the patch:

* Reduces the minimum datum size to be considered for compression from
256 to 32 bytes, as suggested by Greg Stark.  (Greg later suggested
dropping the threshold clear to zero, but this is pointless since we
must save enough bytes to pay for the longer header.)

* Increases the required compression rate for compressed storage from
20% to 25%, again per Greg's suggestion.

* Replaces force_input_size (size above which compression is forced)
with a maximum size to be considered for compression.  It was agreed
that allowing large inputs to escape the minimum-compression-rate
requirement was not bright, and that indeed we'd rather have a knob
that acted in the other direction.  I set this value to 1MB for the
moment, but it could use some performance studies to tune it.

* Adds an early-failure path to the compressor as suggested by Jan:
if it's been unable to find even one compressible substring in the
first 1KB (parameterizable), assume we're looking at incompressible
input and give up.  (There are various ways this could be done, but
this way seems to add the least overhead to the compressor's inner
loop.)

* Improves the toasting heuristics so that when we have very large
fields with attstorage 'x' or 'e', we will push those out to toast
storage before considering inline compression of shorter fields.
This also responds to a suggestion of Greg's, though my original
proposal for a solution was a bit off base because it didn't fix
the problem for large 'e' fields.

There was some discussion in the earlier threads of exposing some
of the compression knobs to users, perhaps even on a per-column
basis.  I have not done anything about that here.  It seems to me
that if we are changing around the parameters, we'd better get some
experience and be sure we are happy with the design before we set
things in stone by providing user-visible knobs.

I have not done any performance testing of these changes --- does
anyone have specific test scenarios they'd like to try?

			regards, tom lane


Attachment: toast-strategy.patch
Description: application/octet-stream (18.6 KB)

Responses

pgsql-patches by date

Next:From: Teodor SigaevDate: 2008-02-18 10:01:38
Subject: Re: Proposed patch to change TOAST compression strategy
Previous:From: Brendan JurdDate: 2008-02-17 10:56:34
Subject: Re: [HACKERS] Show INHERIT in \du

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group