mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
Rename MaxTupleSize to MaxHeapTupleSize to clarify that it's not meant to
describe the maximum size of index tuples (which is typically AM-dependent anyway); and consequently remove the bogus deduction for "special space" that was built into it. Adjust TOAST_TUPLE_THRESHOLD and TOAST_MAX_CHUNK_SIZE to avoid wasting two bytes per toast chunk, and to ensure that the calculation correctly tracks any future changes in page header size. The computation had been inaccurate in a way that didn't cause any harm except space wastage, but future changes could have broken it more drastically. Fix the calculation of BTMaxItemSize, which was formerly computed as 1 byte more than it could safely be. This didn't cause any harm in practice because it's only compared against maxalign'd lengths, but future changes in the size of page headers or btree special space could have exposed the problem. initdb forced because of change in TOAST_MAX_CHUNK_SIZE, which alters the storage of toast tables.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.89 2007/01/09 22:01:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.90 2007/02/05 04:22:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -314,19 +314,17 @@ do { \
|
||||
#define BITMAPLEN(NATTS) (((int)(NATTS) + 7) / 8)
|
||||
|
||||
/*
|
||||
* MaxTupleSize is the maximum allowed size of a tuple, including header and
|
||||
* MAXALIGN alignment padding. Basically it's BLCKSZ minus the other stuff
|
||||
* that has to be on a disk page. The "other stuff" includes access-method-
|
||||
* dependent "special space", which we assume will be no more than
|
||||
* MaxSpecialSpace bytes (currently, on heap pages it's actually zero).
|
||||
* MaxHeapTupleSize is the maximum allowed size of a heap tuple, including
|
||||
* header and MAXALIGN alignment padding. Basically it's BLCKSZ minus the
|
||||
* other stuff that has to be on a disk page. Since heap pages use no
|
||||
* "special space", there's no deduction for that.
|
||||
*
|
||||
* NOTE: we do not need to count an ItemId for the tuple because
|
||||
* sizeof(PageHeaderData) includes the first ItemId on the page.
|
||||
* sizeof(PageHeaderData) includes the first ItemId on the page. But beware
|
||||
* of assuming that, say, you can fit 2 tuples of size MaxHeapTupleSize/2
|
||||
* on the same page.
|
||||
*/
|
||||
#define MaxSpecialSpace 32
|
||||
|
||||
#define MaxTupleSize \
|
||||
(BLCKSZ - MAXALIGN(sizeof(PageHeaderData) + MaxSpecialSpace))
|
||||
#define MaxHeapTupleSize (BLCKSZ - MAXALIGN(sizeof(PageHeaderData)))
|
||||
|
||||
/*
|
||||
* MaxHeapTuplesPerPage is an upper bound on the number of tuples that can
|
||||
|
||||
Reference in New Issue
Block a user