tuples-per-page.patch
text/x-patch
Filename: tuples-per-page.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/backend/access/common/reloptions.c | 9 | 0 |
| src/backend/access/heap/tuptoaster.c | 3 | 1 |
| src/include/utils/rel.h | 8 | 0 |
diff -rc ../postgresql-8.5alpha3.orig/src/backend/access/common/reloptions.c ./src/backend/access/common/reloptions.c
*** ../postgresql-8.5alpha3.orig/src/backend/access/common/reloptions.c 2009-08-27 19:18:44.000000000 +0200
--- ./src/backend/access/common/reloptions.c 2010-02-01 21:12:41.000000000 +0100
***************
*** 15,20 ****
--- 15,21 ----
#include "postgres.h"
+ #include "access/tuptoaster.h"
#include "access/gist_private.h"
#include "access/hash.h"
#include "access/nbtree.h"
***************
*** 157,162 ****
--- 158,170 ----
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
}, -1, 0, 2000000000
},
+ {
+ {
+ "tuples_per_page",
+ "Desired number of tuples per page (worst-case)",
+ RELOPT_KIND_HEAP
+ },TOAST_TUPLES_PER_PAGE , 1,32
+ },
/* list terminator */
{{NULL}}
};
***************
*** 1074,1079 ****
--- 1082,1088 ----
int numoptions;
static const relopt_parse_elt tab[] = {
{"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
+ {"tuples_per_page", RELOPT_TYPE_INT, offsetof(StdRdOptions, tuples_per_page)},
{"autovacuum_enabled", RELOPT_TYPE_BOOL,
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, enabled)},
{"autovacuum_vacuum_threshold", RELOPT_TYPE_INT,
diff -rc ../postgresql-8.5alpha3.orig/src/backend/access/heap/tuptoaster.c ./src/backend/access/heap/tuptoaster.c
*** ../postgresql-8.5alpha3.orig/src/backend/access/heap/tuptoaster.c 2009-07-29 22:56:18.000000000 +0200
--- ./src/backend/access/heap/tuptoaster.c 2010-02-01 21:56:29.000000000 +0100
***************
*** 594,600 ****
hoff = MAXALIGN(hoff);
Assert(hoff == newtup->t_data->t_hoff);
/* now convert to a limit on the tuple data size */
! maxDataLen = TOAST_TUPLE_TARGET - hoff;
/*
* Look for attributes with attstorage 'x' to compress. Also find large
--- 594,602 ----
hoff = MAXALIGN(hoff);
Assert(hoff == newtup->t_data->t_hoff);
/* now convert to a limit on the tuple data size */
!
!
! maxDataLen = MaximumBytesPerTuple(RelationGetTuplesPerPage(rel,TOAST_TUPLES_PER_PAGE)) - hoff;
/*
* Look for attributes with attstorage 'x' to compress. Also find large
diff -rc ../postgresql-8.5alpha3.orig/src/include/utils/rel.h ./src/include/utils/rel.h
*** ../postgresql-8.5alpha3.orig/src/include/utils/rel.h 2009-12-07 06:22:23.000000000 +0100
--- ./src/include/utils/rel.h 2010-02-01 21:33:55.000000000 +0100
***************
*** 239,250 ****
--- 239,258 ----
{
int32 vl_len_; /* varlena header (do not touch directly!) */
int fillfactor; /* page fill factor in percent (0..100) */
+ int tuples_per_page;
AutoVacOpts autovacuum; /* autovacuum-related options */
} StdRdOptions;
#define HEAP_MIN_FILLFACTOR 10
#define HEAP_DEFAULT_FILLFACTOR 100
+ /* RelationGetTuplesPerPage
+ * Returns the desirec number of tuples per page.
+ */
+ #define RelationGetTuplesPerPage(relation,defaulttpp) \
+ ((relation)->rd_options ? \
+ ((StdRdOptions *) (relation)->rd_options)->tuples_per_page : (defaulttpp))
+
/*
* RelationGetFillFactor
* Returns the relation's fillfactor. Note multiple eval of argument!