Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d83138

Browse files
committed
Rationalize vacuuming options and parameters
We were involving the parser too much in setting up initial vacuumingparameters. This patch moves that responsibility elsewhere to simplifycode, and also to make future additions easier. To do this, create anew struct VacuumParams which is filled just prior to vacuum execution,instead of at parse time; for user-invoked vacuuming this is set up in anew function ExecVacuum, while autovacuum sets it up by itself.While at it, add a new member VACOPT_SKIPTOAST to enum VacuumOption,only set by autovacuum, which is used to disable vacuuming of the toasttable instead of the old do_toast parameter; this relieves the argumentlist of vacuum() and some callees a bit. This partially makes up forhaving added more arguments in an effort to avoid having autovacuum fromconstructing a VacuumStmt parse node.Author: Michael Paquier. Some tweaks by ÁlvaroReviewed by: Robert Haas, Stephen Frost, Álvaro Herrera
1 parent4559167 commit0d83138

File tree

10 files changed

+159
-170
lines changed

10 files changed

+159
-170
lines changed

‎src/backend/commands/analyze.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static MemoryContext anl_context = NULL;
8585
staticBufferAccessStrategyvac_strategy;
8686

8787

88-
staticvoiddo_analyze_rel(Relationonerel,VacuumStmt*vacstmt,
88+
staticvoiddo_analyze_rel(Relationonerel,intoptions,List*va_cols,
8989
AcquireSampleRowsFuncacquirefunc,BlockNumberrelpages,
9090
boolinh,boolin_outer_xact,intelevel);
9191
staticvoidBlockSampler_Init(BlockSamplerbs,BlockNumbernblocks,
@@ -115,7 +115,7 @@ static Datum ind_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull);
115115
*analyze_rel() -- analyze one relation
116116
*/
117117
void
118-
analyze_rel(Oidrelid,VacuumStmt*vacstmt,
118+
analyze_rel(Oidrelid,RangeVar*relation,intoptions,List*va_cols,
119119
boolin_outer_xact,BufferAccessStrategybstrategy)
120120
{
121121
Relationonerel;
@@ -124,7 +124,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
124124
BlockNumberrelpages=0;
125125

126126
/* Select logging level */
127-
if (vacstmt->options&VACOPT_VERBOSE)
127+
if (options&VACOPT_VERBOSE)
128128
elevel=INFO;
129129
else
130130
elevel=DEBUG2;
@@ -144,7 +144,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
144144
* matter if we ever try to accumulate stats on dead tuples.) If the rel
145145
* has been dropped since we last saw it, we don't need to process it.
146146
*/
147-
if (!(vacstmt->options&VACOPT_NOWAIT))
147+
if (!(options&VACOPT_NOWAIT))
148148
onerel=try_relation_open(relid,ShareUpdateExclusiveLock);
149149
elseif (ConditionalLockRelationOid(relid,ShareUpdateExclusiveLock))
150150
onerel=try_relation_open(relid,NoLock);
@@ -155,7 +155,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
155155
ereport(LOG,
156156
(errcode(ERRCODE_LOCK_NOT_AVAILABLE),
157157
errmsg("skipping analyze of \"%s\" --- lock not available",
158-
vacstmt->relation->relname)));
158+
relation->relname)));
159159
}
160160
if (!onerel)
161161
return;
@@ -167,7 +167,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
167167
(pg_database_ownercheck(MyDatabaseId,GetUserId())&& !onerel->rd_rel->relisshared)))
168168
{
169169
/* No need for a WARNING if we already complained during VACUUM */
170-
if (!(vacstmt->options&VACOPT_VACUUM))
170+
if (!(options&VACOPT_VACUUM))
171171
{
172172
if (onerel->rd_rel->relisshared)
173173
ereport(WARNING,
@@ -248,7 +248,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
248248
else
249249
{
250250
/* No need for a WARNING if we already complained during VACUUM */
251-
if (!(vacstmt->options&VACOPT_VACUUM))
251+
if (!(options&VACOPT_VACUUM))
252252
ereport(WARNING,
253253
(errmsg("skipping \"%s\" --- cannot analyze non-tables or special system tables",
254254
RelationGetRelationName(onerel))));
@@ -266,14 +266,14 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
266266
/*
267267
* Do the normal non-recursive ANALYZE.
268268
*/
269-
do_analyze_rel(onerel,vacstmt,acquirefunc,relpages,
269+
do_analyze_rel(onerel,options,va_cols,acquirefunc,relpages,
270270
false,in_outer_xact,elevel);
271271

272272
/*
273273
* If there are child tables, do recursive ANALYZE.
274274
*/
275275
if (onerel->rd_rel->relhassubclass)
276-
do_analyze_rel(onerel,vacstmt,acquirefunc,relpages,
276+
do_analyze_rel(onerel,options,va_cols,acquirefunc,relpages,
277277
true,in_outer_xact,elevel);
278278

279279
/*
@@ -302,7 +302,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
302302
* acquirefunc for each child table.
303303
*/
304304
staticvoid
305-
do_analyze_rel(Relationonerel,VacuumStmt*vacstmt,
305+
do_analyze_rel(Relationonerel,intoptions,List*va_cols,
306306
AcquireSampleRowsFuncacquirefunc,BlockNumberrelpages,
307307
boolinh,boolin_outer_xact,intelevel)
308308
{
@@ -372,14 +372,14 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt,
372372
*
373373
* Note that system attributes are never analyzed.
374374
*/
375-
if (vacstmt->va_cols!=NIL)
375+
if (va_cols!=NIL)
376376
{
377377
ListCell*le;
378378

379-
vacattrstats= (VacAttrStats**)palloc(list_length(vacstmt->va_cols)*
379+
vacattrstats= (VacAttrStats**)palloc(list_length(va_cols)*
380380
sizeof(VacAttrStats*));
381381
tcnt=0;
382-
foreach(le,vacstmt->va_cols)
382+
foreach(le,va_cols)
383383
{
384384
char*col=strVal(lfirst(le));
385385

@@ -436,7 +436,7 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt,
436436

437437
thisdata->indexInfo=indexInfo=BuildIndexInfo(Irel[ind]);
438438
thisdata->tupleFract=1.0;/* fix later if partial */
439-
if (indexInfo->ii_Expressions!=NIL&&vacstmt->va_cols==NIL)
439+
if (indexInfo->ii_Expressions!=NIL&&va_cols==NIL)
440440
{
441441
ListCell*indexpr_item=list_head(indexInfo->ii_Expressions);
442442

@@ -595,7 +595,7 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt,
595595
* VACUUM ANALYZE, don't overwrite the accurate count already inserted by
596596
* VACUUM.
597597
*/
598-
if (!inh&& !(vacstmt->options&VACOPT_VACUUM))
598+
if (!inh&& !(options&VACOPT_VACUUM))
599599
{
600600
for (ind=0;ind<nindexes;ind++)
601601
{
@@ -623,7 +623,7 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt,
623623
pgstat_report_analyze(onerel,totalrows,totaldeadrows);
624624

625625
/* If this isn't part of VACUUM ANALYZE, let index AMs do cleanup */
626-
if (!(vacstmt->options&VACOPT_VACUUM))
626+
if (!(options&VACOPT_VACUUM))
627627
{
628628
for (ind=0;ind<nindexes;ind++)
629629
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp