|
6 | 6 | *
|
7 | 7 | * Copyright (c) 2000-2009, PostgreSQL Global Development Group
|
8 | 8 | *
|
9 |
| - * $PostgreSQL: pgsql/src/include/access/tuptoaster.h,v 1.43 2009/01/01 17:23:56 momjian Exp $ |
| 9 | + * $PostgreSQL: pgsql/src/include/access/tuptoaster.h,v 1.44 2009/07/22 01:21:22 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
|
24 | 24 | #define TOAST_INDEX_HACK
|
25 | 25 |
|
26 | 26 |
|
| 27 | +/* |
| 28 | + * Find the maximum size of a tuple if there are to be N tuples per page. |
| 29 | + */ |
| 30 | +#define MaximumBytesPerTuple(tuplesPerPage) \ |
| 31 | + MAXALIGN_DOWN((BLCKSZ - \ |
| 32 | + MAXALIGN(SizeOfPageHeaderData + (tuplesPerPage) * sizeof(ItemIdData))) \ |
| 33 | + / (tuplesPerPage)) |
| 34 | + |
27 | 35 | /*
|
28 | 36 | * These symbols control toaster activation. If a tuple is larger than
|
29 | 37 | * TOAST_TUPLE_THRESHOLD, we will try to toast it down to no more than
|
30 |
| - * TOAST_TUPLE_TARGET bytes. Both numbers include all tuple header overhead |
31 |
| - * and between-fields alignment padding, but we do *not* consider any |
32 |
| - * end-of-tuple alignment padding; hence the values can be compared directly |
33 |
| - * to a tuple's t_len field. |
| 38 | + * TOAST_TUPLE_TARGET bytes through compressing compressible fields and |
| 39 | + * moving EXTENDED and EXTERNAL data out-of-line. |
34 | 40 | *
|
35 | 41 | * The numbers need not be the same, though they currently are. It doesn't
|
36 | 42 | * make sense for TARGET to exceed THRESHOLD, but it could be useful to make
|
37 | 43 | * it be smaller.
|
38 | 44 | *
|
39 | 45 | * Currently we choose both values to match the largest tuple size for which
|
40 |
| - * TOAST_TUPLES_PER_PAGE tuples can fit on a disk page. |
| 46 | + * TOAST_TUPLES_PER_PAGE tuples can fit on a heap page. |
41 | 47 | *
|
42 | 48 | * XXX while these can be modified without initdb, some thought needs to be
|
43 | 49 | * given to needs_toast_table() in toasting.c before unleashing random
|
|
46 | 52 | */
|
47 | 53 | #define TOAST_TUPLES_PER_PAGE 4
|
48 | 54 |
|
49 |
| -#define TOAST_TUPLE_THRESHOLD \ |
50 |
| - MAXALIGN_DOWN((BLCKSZ - \ |
51 |
| - MAXALIGN(SizeOfPageHeaderData + TOAST_TUPLES_PER_PAGE * sizeof(ItemIdData))) \ |
52 |
| - / TOAST_TUPLES_PER_PAGE) |
| 55 | +#define TOAST_TUPLE_THRESHOLD MaximumBytesPerTuple(TOAST_TUPLES_PER_PAGE) |
53 | 56 |
|
54 | 57 | #define TOAST_TUPLE_TARGET TOAST_TUPLE_THRESHOLD
|
55 | 58 |
|
| 59 | +/* |
| 60 | + * The code will also consider moving MAIN data out-of-line, but only as a |
| 61 | + * last resort if the previous steps haven't reached the target tuple size. |
| 62 | + * In this phase we use a different target size, currently equal to the |
| 63 | + * largest tuple that will fit on a heap page. This is reasonable since |
| 64 | + * the user has told us to keep the data in-line if at all possible. |
| 65 | + */ |
| 66 | +#define TOAST_TUPLES_PER_PAGE_MAIN 1 |
| 67 | + |
| 68 | +#define TOAST_TUPLE_TARGET_MAIN MaximumBytesPerTuple(TOAST_TUPLES_PER_PAGE_MAIN) |
| 69 | + |
56 | 70 | /*
|
57 | 71 | * If an index value is larger than TOAST_INDEX_TARGET, we will try to
|
58 | 72 | * compress it (we can't move it out-of-line, however). Note that this
|
|
72 | 86 | */
|
73 | 87 | #define EXTERN_TUPLES_PER_PAGE 4 /* tweak only this */
|
74 | 88 |
|
75 |
| -#define EXTERN_TUPLE_MAX_SIZE \ |
76 |
| - MAXALIGN_DOWN((BLCKSZ - \ |
77 |
| - MAXALIGN(SizeOfPageHeaderData + EXTERN_TUPLES_PER_PAGE * sizeof(ItemIdData))) \ |
78 |
| - / EXTERN_TUPLES_PER_PAGE) |
| 89 | +#define EXTERN_TUPLE_MAX_SIZE MaximumBytesPerTuple(EXTERN_TUPLES_PER_PAGE) |
79 | 90 |
|
80 | 91 | #define TOAST_MAX_CHUNK_SIZE \
|
81 | 92 | (EXTERN_TUPLE_MAX_SIZE - \
|
|
0 commit comments