Multiple tables can be vacuumed by writing multiple
<option>-t</option> switches.
</para>
+ <para>
+ If no tables are specified with the <option>--table</option> option,
+ <application>vacuumdb</application> will clean all regular tables
+ and materialized views in the connected database.
+ If <option>--analyze-only</option> or
+ <option>--analyze-in-stages</option> is also specified,
+ it will analyze all regular tables, partitioned tables,
+ and materialized views (but not foreign tables).
+ </para>
<tip>
<para>
If you specify columns, you probably have to escape the parentheses
qr/statement:\ ANALYZE/sx,
'--missing-stats-only with no missing partition stats');
+$node->safe_psql('postgres',
+ "CREATE TABLE parent_table (a INT) PARTITION BY LIST (a);\n"
+ . "CREATE TABLE child_table PARTITION OF parent_table FOR VALUES IN (1);\n"
+ . "INSERT INTO parent_table VALUES (1);\n");
+$node->issues_sql_like(
+ [
+ 'vacuumdb', '--analyze-only', 'postgres'
+ ],
+ qr/statement: ANALYZE public.parent_table/s,
+ '--analyze-only updates statistics for partitioned tables');
+
done_testing();
*/
if ((objfilter & OBJFILTER_TABLE) == 0)
{
- appendPQExpBufferStr(&catalog_query,
- " AND c.relkind OPERATOR(pg_catalog.=) ANY (array["
- CppAsString2(RELKIND_RELATION) ", "
- CppAsString2(RELKIND_MATVIEW) "])\n");
+ /*
+ * vacuumdb should generally follow the behavior of the underlying
+ * VACUUM and ANALYZE commands. If analyze_only is true, process
+ * regular tables, materialized views, and partitioned tables, just
+ * like ANALYZE (with no specific target tables) does. Otherwise,
+ * process only regular tables and materialized views, since VACUUM
+ * skips partitioned tables when no target tables are specified.
+ */
+ if (vacopts->analyze_only)
+ appendPQExpBufferStr(&catalog_query,
+ " AND c.relkind OPERATOR(pg_catalog.=) ANY (array["
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_PARTITIONED_TABLE) "])\n");
+ else
+ appendPQExpBufferStr(&catalog_query,
+ " AND c.relkind OPERATOR(pg_catalog.=) ANY (array["
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) "])\n");
+
}
/*