Re: [Proposal] Allow users to specify multiple tables in VACUUM commands
Masahiko Sawada <sawada.mshk@gmail.com>
From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, "Bossart, Nathan" <bossartn@amazon.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2017-05-11T03:10:15Z
Lists: pgsql-hackers
On Thu, May 11, 2017 at 11:13 AM, Michael Paquier <michael.paquier@gmail.com> wrote: > On Thu, May 11, 2017 at 6:40 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> "Bossart, Nathan" <bossartn@amazon.com> writes: >>> Currently, VACUUM commands allow you to specify one table or all of the tables in the current database to vacuum. I’ve recently found myself wishing I could specify multiple tables in a single VACUUM statement. For example, this would be convenient when there are several large tables in a database and only a few need cleanup for XID purposes. Is this a feature that the community might be interested in? >> >> I'm a bit surprised to realize that we don't allow that, since the >> underlying code certainly can do it. >> >> You realize of course that ANALYZE should grow this capability as well. > > Yup. It is just a matter of extending ExecVacuum() to handle a list of > qualified names with a quick look at the grammar as we are talking > only about manual commands. One question I am wondering though is do > we want to have everything happening in the same transaction? I would > say yes to that to simplify the code. I think that VERBOSE should also > report the per-table information, so this can be noisy with many > tables but that's more helpful than gathering all the results. I agree to report per-table information. Especially In case of one of tables specified failed during vacuuming, I think we should report at least information of tables that is done successfully so far. > >>> I’ve attached my first attempt at introducing this functionality. In the patch, I’ve extended the table_name parameter in the VACUUM grammar to a qualified_name_list. While this fits into the grammar decently well, I suspect that it may be desirable to be able to specify a column list for each table as well (e.g. VACUUM foo (a), bar (b)). >> >> The column list only matters for ANALYZE (or VACUUM ANALYZE). But yes, >> it should be per-table. > > The grammar allows that by the way: > =# VACUUM (full) aa (a); > VACUUM > Perhaps that's an oversight? I don't think it makes much sense. > -- > Michael > > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers Regards, -- Masahiko Sawada NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center
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