Re: [Proposal] Allow users to specify multiple tables in VACUUM commands
Nathan Bossart <bossartn@amazon.com>
From: "Bossart, Nathan" <bossartn@amazon.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>,
"David G. Johnston" <david.g.johnston@gmail.com>,
Robert Haas <robertmhaas@gmail.com>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>,
Tom Lane <tgl@sss.pgh.pa.us>
Date: 2017-09-01T18:00:51Z
Lists: pgsql-hackers
Attachments
- dedupe_vacuum_relations_v3.patch (application/octet-stream) patch v3
- vacuum_multiple_tables_v13.patch (application/octet-stream) patch v13
On 9/1/17, 12:11 AM, "Michael Paquier" <michael.paquier@gmail.com> wrote:
> Hm. Here is the diff between v11 and v12:
> static void
> autovacuum_do_vac_analyze(autovac_table *tab, BufferAccessStrategy bstrategy)
> {
> - RangeVar rangevar;
> - VacuumRelation *rel;
> -
> - /* Set up command parameters --- use local variables instead of palloc */
> - MemSet(&rangevar, 0, sizeof(rangevar));
> -
> - rangevar.schemaname = tab->at_nspname;
> - rangevar.relname = tab->at_relname;
> - rangevar.location = -1;
> + RangeVar *rangevar;
> + VacuumRelation *rel;
>
> /* Let pgstat know what we're doing */
> autovac_report_activity(tab);
>
> - rel = makeVacuumRelation(&rangevar, NIL, tab->at_relid);
> + rangevar = makeRangeVar(tab->at_nspname, tab->at_relname, -1);
> + rel = makeVacuumRelation(rangevar, NIL, tab->at_relid);
> But there is this commit in vacuum.c:
> * It is the caller's responsibility that all parameters are allocated
> in a
> * memory context that will not disappear at transaction commit.
> And I don't think we want to break that promise as newNode() uses
> palloc0fast() which allocates data in the current memory context (see
> 4873c96f). I think that you had better just use NodeSetTag here and be
> done with it. Also, it seems to me that this could be fixed as a
> separate patch. It is definitely an incorrect pattern...
Don't we have a similar problem with makeVacuumRelation() and list_make1()?
I went ahead and moved the RangeVar, VacuumRelation, and List into local
variables for now, but I agree that this could be improved in a separate
patch. Perhaps these could be allocated in AutovacMemCxt. I see from
4873c96f that autovacuum_do_vac_analyze() used to allocate the list of OIDs
in that "long-lived" memory context.
> - $$ = (Node *)n;
> + $$ = (Node *) n;
> Spurious noise. And the coding pattern in gram.y is to not add a space
> (make new code look like its surroundings as the documentation says).
I've fixed this in v13.
Nathan
Commits
-
Allow multiple tables to be specified in one VACUUM or ANALYZE command.
- 11d8d72c27a6 11.0 landed
-
Give a better error for duplicate entries in VACUUM/ANALYZE column list.
- ea31541f5648 9.6.6 landed
- e56facd8b300 9.2.24 landed
- b572b435ca67 9.4.15 landed
- a2b1eb23496e 10.0 landed
- a09d8be7ddaf 9.3.20 landed
- 71480501057f 11.0 landed
- 122289a66b92 9.5.10 landed
-
Reject ANALYZE commands during VACUUM FULL or another ANALYZE.
- e415b469b33b 9.5.0 cited