Skip to content

Commit b5faba1

Browse files
committed
Ensure default-only storage parameters for TOAST relations
to be initialized with proper values. Affected parameters are fillfactor, analyze_threshold, and analyze_scale_factor. Especially uninitialized fillfactor caused inefficient page usage because we built a StdRdOptions struct in which fillfactor is zero if any reloption is set for the toast table. In addition, we disallow toast.autovacuum_analyze_threshold and toast.autovacuum_analyze_scale_factor because we didn't actually support them; they are always ignored. Report by Rumko on pgsql-bugs on 12 May 2010. Analysis by Tom Lane and Alvaro Herrera. Patch by me. Backpatch to 8.4.
1 parent 3fd8399 commit b5faba1

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

doc/src/sgml/ref/create_table.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.127 2010/05/13 18:54:18 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.128 2010/06/07 02:59:02 itagaki Exp $
33
PostgreSQL documentation
44
-->
55

@@ -880,7 +880,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PAR
880880
</varlistentry>
881881

882882
<varlistentry>
883-
<term><literal>autovacuum_analyze_threshold</>, <literal>toast.autovacuum_analyze_threshold</literal> (<type>integer</>)</term>
883+
<term><literal>autovacuum_analyze_threshold</> (<type>integer</>)</term>
884884
<listitem>
885885
<para>
886886
Minimum number of inserted, updated, or deleted tuples before initiate an
@@ -890,7 +890,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PAR
890890
</varlistentry>
891891

892892
<varlistentry>
893-
<term><literal>autovacuum_analyze_scale_factor</>, <literal>toast.autovacuum_analyze_scale_factor</literal> (<type>float4</>)</term>
893+
<term><literal>autovacuum_analyze_scale_factor</> (<type>float4</>)</term>
894894
<listitem>
895895
<para>
896896
Multiplier for <structfield>reltuples</> to add to

src/backend/access/common/reloptions.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.34 2010/03/11 21:47:19 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.35 2010/06/07 02:59:02 itagaki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -116,7 +116,7 @@ static relopt_int intRelOpts[] =
116116
{
117117
"autovacuum_analyze_threshold",
118118
"Minimum number of tuple inserts, updates or deletes prior to analyze",
119-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
119+
RELOPT_KIND_HEAP
120120
},
121121
-1, 0, INT_MAX
122122
},
@@ -177,7 +177,7 @@ static relopt_real realRelOpts[] =
177177
{
178178
"autovacuum_analyze_scale_factor",
179179
"Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples",
180-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
180+
RELOPT_KIND_HEAP
181181
},
182182
-1, 0.0, 100.0
183183
},
@@ -1156,10 +1156,21 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
11561156
bytea *
11571157
heap_reloptions(char relkind, Datum reloptions, bool validate)
11581158
{
1159+
StdRdOptions *rdopts;
1160+
11591161
switch (relkind)
11601162
{
11611163
case RELKIND_TOASTVALUE:
1162-
return default_reloptions(reloptions, validate, RELOPT_KIND_TOAST);
1164+
rdopts = (StdRdOptions *)
1165+
default_reloptions(reloptions, validate, RELOPT_KIND_TOAST);
1166+
if (rdopts != NULL)
1167+
{
1168+
/* adjust default-only parameters for TOAST relations */
1169+
rdopts->fillfactor = 100;
1170+
rdopts->autovacuum.analyze_threshold = -1;
1171+
rdopts->autovacuum.analyze_scale_factor = -1;
1172+
}
1173+
return (bytea *) rdopts;
11631174
case RELKIND_RELATION:
11641175
return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);
11651176
default:

src/bin/psql/tab-complete.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.198 2010/04/07 03:51:19 itagaki Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.199 2010/06/07 02:59:02 itagaki Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -1172,8 +1172,6 @@ psql_completion(char *text, int start, int end)
11721172
"autovacuum_vacuum_scale_factor",
11731173
"autovacuum_vacuum_threshold",
11741174
"fillfactor",
1175-
"toast.autovacuum_analyze_scale_factor",
1176-
"toast.autovacuum_analyze_threshold",
11771175
"toast.autovacuum_enabled",
11781176
"toast.autovacuum_freeze_max_age",
11791177
"toast.autovacuum_freeze_min_age",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy