Re: Modifying TOAST thresholds

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Modifying TOAST thresholds
Date: 2007-04-03 04:21:16
Message-ID: 17443.1175574076@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Gregory Stark <stark(at)enterprisedb(dot)com> writes:
>> Is there any reason to experiment with this? I would have thought we would
>> divorce TOAST_MAX_CHUNK_SIZE from TOAST_THRESHOLD and hard code it as the same
>> expression that's there now. Ie, the largest size that can fit in a page.

> No, right now it's the largest size that you can fit 4 on a page. It's
> not obvious to me that 4 is optimal once it's divorced from TOAST_THRESHOLD.
> It seems possible that the correct number is 1, and even if it's useful
> to keep the tuples smaller than that, there's no reason to assume 4 is
> the best number per page.

I've just committed changes that make it trivial to experiment with the
number of toast tuples per page:

#define EXTERN_TUPLES_PER_PAGE 4 /* tweak only this */

/* Note: sizeof(PageHeaderData) includes the first ItemId on the page */
#define EXTERN_TUPLE_MAX_SIZE \
MAXALIGN_DOWN((BLCKSZ - \
MAXALIGN(sizeof(PageHeaderData) + (EXTERN_TUPLES_PER_PAGE-1) * sizeof(ItemIdData))) \
/ EXTERN_TUPLES_PER_PAGE)

#define TOAST_MAX_CHUNK_SIZE \
(EXTERN_TUPLE_MAX_SIZE - \
MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) - \
sizeof(Oid) - \
sizeof(int32) - \
VARHDRSZ)

Anyone who's got time to run performance experiments, have at it ...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-04-03 04:26:41 Re: Modifying TOAST thresholds
Previous Message Chris Browne 2007-04-03 04:18:16 Re: Modifying TOAST thresholds