|
6 | 6 | *
|
7 | 7 | * Copyright (c) 2000-2007, PostgreSQL Global Development Group
|
8 | 8 | *
|
9 |
| - * $PostgreSQL: pgsql/src/include/access/tuptoaster.h,v 1.31 2007/02/04 20:00:37 tgl Exp $ |
| 9 | + * $PostgreSQL: pgsql/src/include/access/tuptoaster.h,v 1.32 2007/02/05 04:22:18 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
|
29 | 29 | * TOAST_TUPLE_TARGET bytes. Both numbers include all tuple header overhead
|
30 | 30 | * and between-fields alignment padding, but we do *not* consider any
|
31 | 31 | * end-of-tuple alignment padding; hence the values can be compared directly
|
32 |
| - * to a tuple's t_len field. (Note that the symbol values are not |
33 |
| - * necessarily MAXALIGN multiples.) |
| 32 | + * to a tuple's t_len field. We choose TOAST_TUPLE_THRESHOLD with the |
| 33 | + * knowledge that toast-table tuples will be exactly that size, and we'd |
| 34 | + * like to fit four of them per page with minimal space wastage. |
34 | 35 | *
|
35 | 36 | * The numbers need not be the same, though they currently are.
|
| 37 | + * |
| 38 | + * Note: sizeof(PageHeaderData) includes the first ItemId, but we have |
| 39 | + * to allow for 3 more, if we want to fit 4 tuples on a page. |
36 | 40 | */
|
37 |
| -#define TOAST_TUPLE_THRESHOLD (MaxTupleSize / 4) |
| 41 | +#define TOAST_TUPLE_THRESHOLD \ |
| 42 | + MAXALIGN_DOWN((BLCKSZ - \ |
| 43 | + MAXALIGN(sizeof(PageHeaderData) + 3 * sizeof(ItemIdData))) \ |
| 44 | + / 4) |
38 | 45 |
|
39 |
| -#define TOAST_TUPLE_TARGET (MaxTupleSize / 4) |
| 46 | +#define TOAST_TUPLE_TARGET TOAST_TUPLE_THRESHOLD |
40 | 47 |
|
41 | 48 | /*
|
42 | 49 | * If an index value is larger than TOAST_INDEX_TARGET, we will try to
|
43 | 50 | * compress it (we can't move it out-of-line, however). Note that this
|
44 | 51 | * number is per-datum, not per-tuple, for simplicity in index_form_tuple().
|
45 | 52 | */
|
46 |
| -#define TOAST_INDEX_TARGET (MaxTupleSize / 16) |
| 53 | +#define TOAST_INDEX_TARGET (MaxHeapTupleSize / 16) |
47 | 54 |
|
48 | 55 | /*
|
49 | 56 | * When we store an oversize datum externally, we divide it into chunks
|
50 | 57 | * containing at most TOAST_MAX_CHUNK_SIZE data bytes. This number *must*
|
51 | 58 | * be small enough that the completed toast-table tuple (including the
|
52 |
| - * ID and sequence fields and all overhead) is no more than MaxTupleSize |
| 59 | + * ID and sequence fields and all overhead) is no more than MaxHeapTupleSize |
53 | 60 | * bytes. It *should* be small enough to make toast-table tuples no more
|
54 | 61 | * than TOAST_TUPLE_THRESHOLD bytes, else heapam.c will uselessly invoke
|
55 |
| - * the toaster on toast-table tuples. |
| 62 | + * the toaster on toast-table tuples. The current coding ensures that the |
| 63 | + * maximum tuple length is exactly TOAST_TUPLE_THRESHOLD bytes. |
56 | 64 | *
|
57 | 65 | * NB: you cannot change this value without forcing initdb, at least not
|
58 | 66 | * if your DB contains any multi-chunk toasted values.
|
59 | 67 | */
|
60 | 68 | #define TOAST_MAX_CHUNK_SIZE (TOAST_TUPLE_THRESHOLD - \
|
61 |
| - MAXALIGN( \ |
62 |
| - MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + \ |
63 |
| - sizeof(Oid) + \ |
64 |
| - sizeof(int32) + \ |
65 |
| - VARHDRSZ)) |
| 69 | + MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) - \ |
| 70 | + sizeof(Oid) - \ |
| 71 | + sizeof(int32) - \ |
| 72 | + VARHDRSZ) |
66 | 73 |
|
67 | 74 |
|
68 | 75 | /* ----------
|
|
0 commit comments