aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItagaki Takahiro <itagaki.takahiro@gmail.com>2010-06-07 03:01:35 +0000
committerItagaki Takahiro <itagaki.takahiro@gmail.com>2010-06-07 03:01:35 +0000
commit634b1614a05edc0cf2b70097818dba5a9314fc27 (patch)
tree3e8f2ee6eafaf1ff47b96997820bb3bb646b09e2
parent32c6702f4d265dc7e25bec88c098f4a13f5cf7bf (diff)
downloadpostgresql-634b1614a05edc0cf2b70097818dba5a9314fc27.tar.gz
postgresql-634b1614a05edc0cf2b70097818dba5a9314fc27.zip
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.
-rw-r--r--doc/src/sgml/ref/create_table.sgml6
-rw-r--r--src/backend/access/common/reloptions.c19
2 files changed, 18 insertions, 7 deletions
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 1d0b8a4904f..01270faf4c6 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.114.2.2 2010/05/13 18:54:23 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.114.2.3 2010/06/07 03:01:34 itagaki Exp $
PostgreSQL documentation
-->
@@ -770,7 +770,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</varlistentry>
<varlistentry>
- <term><literal>autovacuum_analyze_threshold</>, <literal>toast.autovacuum_analyze_threshold</literal> (<type>integer</>)</term>
+ <term><literal>autovacuum_analyze_threshold</> (<type>integer</>)</term>
<listitem>
<para>
Minimum number of inserted, updated, or deleted tuples before initiate an
@@ -780,7 +780,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</varlistentry>
<varlistentry>
- <term><literal>autovacuum_analyze_scale_factor</>, <literal>toast.autovacuum_analyze_scale_factor</literal> (<type>float4</>)</term>
+ <term><literal>autovacuum_analyze_scale_factor</> (<type>float4</>)</term>
<listitem>
<para>
Multiplier for <structfield>reltuples</> to add to
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 83c41b3da41..5cc66c34342 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.28.2.2 2010/03/11 21:47:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.28.2.3 2010/06/07 03:01:35 itagaki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -114,7 +114,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_analyze_threshold",
"Minimum number of tuple inserts, updates or deletes prior to analyze",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
+ RELOPT_KIND_HEAP
},
-1, 0, INT_MAX
},
@@ -175,7 +175,7 @@ static relopt_real realRelOpts[] =
{
"autovacuum_analyze_scale_factor",
"Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
+ RELOPT_KIND_HEAP
},
-1, 0.0, 100.0
},
@@ -1122,10 +1122,21 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
bytea *
heap_reloptions(char relkind, Datum reloptions, bool validate)
{
+ StdRdOptions *rdopts;
+
switch (relkind)
{
case RELKIND_TOASTVALUE:
- return default_reloptions(reloptions, validate, RELOPT_KIND_TOAST);
+ rdopts = (StdRdOptions *)
+ default_reloptions(reloptions, validate, RELOPT_KIND_TOAST);
+ if (rdopts != NULL)
+ {
+ /* adjust default-only parameters for TOAST relations */
+ rdopts->fillfactor = 100;
+ rdopts->autovacuum.analyze_threshold = -1;
+ rdopts->autovacuum.analyze_scale_factor = -1;
+ }
+ return (bytea *) rdopts;
case RELKIND_RELATION:
return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);
default: