From 4cc7a93d220644ae068ce2639b961db6764a68f6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 22 Jun 2005 21:14:31 +0000 Subject: Make REINDEX DATABASE do what one would expect, namely reindex all indexes in the database. The old behavior (reindex system catalogs only) is now available as REINDEX SYSTEM. I did not add the complementary REINDEX USER case since there did not seem to be consensus for this, but it would be trivial to add later. Per recent discussions. --- doc/src/sgml/maintenance.sgml | 5 ++-- doc/src/sgml/ref/reindex.sgml | 63 ++++++++++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 21 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index d68cd817c31..b9ce518554b 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -1,5 +1,5 @@ @@ -468,8 +468,7 @@ HINT: Stop the postmaster and use a standalone backend to VACUUM in "mydb". In some situations it is worthwhile to rebuild indexes periodically - with the REINDEX command. (There is also - contrib/reindexdb which can reindex an entire database.) + with the REINDEX command. However, PostgreSQL 7.4 has substantially reduced the need for this activity compared to earlier releases. diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml index 9579b95e237..4bb6b9ff756 100644 --- a/doc/src/sgml/ref/reindex.sgml +++ b/doc/src/sgml/ref/reindex.sgml @@ -1,5 +1,5 @@ @@ -20,7 +20,7 @@ PostgreSQL documentation -REINDEX { DATABASE | TABLE | INDEX } name [ FORCE ] +REINDEX { INDEX | TABLE | DATABASE | SYSTEM } name [ FORCE ] @@ -28,7 +28,7 @@ REINDEX { DATABASE | TABLE | INDEX } nameDescription - REINDEX rebuilds an index based on the data + REINDEX rebuilds an index using the data stored in the index's table, replacing the old copy of the index. There are two main reasons to use REINDEX: @@ -63,12 +63,10 @@ REINDEX { DATABASE | TABLE | INDEX } name - DATABASE + INDEX - Recreate all system indexes of a specified database. Indexes on - user tables are not processed. Also, indexes on shared system - catalogs are skipped except in stand-alone mode (see below). + Recreate the specified index. @@ -77,17 +75,30 @@ REINDEX { DATABASE | TABLE | INDEX } nameTABLE - Recreate all indexes of a specified table. If the table has a + Recreate all indexes of the specified table. If the table has a secondary TOAST table, that is reindexed as well. - INDEX + DATABASE - Recreate a specified index. + Recreate all indexes within the current database. + Indexes on shared system catalogs are skipped except in stand-alone mode + (see below). + + + + + + SYSTEM + + + Recreate all indexes on system catalogs within the current database. + Indexes on user tables are not processed. Also, indexes on shared + system catalogs are skipped except in stand-alone mode (see below). @@ -96,10 +107,11 @@ REINDEX { DATABASE | TABLE | INDEX } namename - The name of the specific database, table, or index to be - reindexed. Table and index names may be schema-qualified. - Presently, REINDEX DATABASE can only reindex the current - database, so its parameter must match the current database's name. + The name of the specific index, table, or database to be + reindexed. Index and table names may be schema-qualified. + Presently, REINDEX DATABASE and REINDEX SYSTEM + can only reindex the current database, so their parameter must match + the current database's name. @@ -139,10 +151,10 @@ REINDEX { DATABASE | TABLE | INDEX } namePostgreSQL server with the option included on its command line. - Then, REINDEX DATABASE, + Then, REINDEX DATABASE, REINDEX SYSTEM, REINDEX TABLE, or REINDEX INDEX can be issued, depending on how much you want to reconstruct. If in - doubt, use REINDEX DATABASE to select + doubt, use REINDEX SYSTEM to select reconstruction of all system indexes in the database. Then quit the standalone server session and restart the regular server. See the reference page for more @@ -199,6 +211,21 @@ REINDEX { DATABASE | TABLE | INDEX } nameREINDEX does not. + + Reindexing a single index or table requires being the owner of that + index or table. Reindexing a database requires being the owner of + the database (note that the owner can therefore rebuild indexes of + tables owned by other users). Of course, superusers can always + reindex anything. + + + + Prior to PostgreSQL 8.1, REINDEX + DATABASE processed only system indexes, not all indexes as one would + expect from the name. This has been changed to reduce the surprise + factor. The old behavior is available as REINDEX SYSTEM. + + Prior to PostgreSQL 7.4, REINDEX TABLE did not automatically process TOAST tables, and so those had @@ -227,8 +254,8 @@ REINDEX INDEX my_index; - Rebuild all system indexes in a particular database, without trusting them - to be valid already: + Rebuild all indexes in a particular database, without trusting the + system indexes to be valid already: $ export PGOPTIONS="-P" -- cgit v1.2.3