1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-23 14:01:44 +03:00

Get rid of cluster.c's apparatus for rebuilding a relation's indexes

in favor of using the REINDEX TABLE apparatus, which does the same thing
simpler and faster.  Also, make TRUNCATE not use cluster.c at all, but
just assign a new relfilenode and REINDEX.  This partially addresses
Hartmut Raschick's complaint from last December that 7.4's TRUNCATE is
an order of magnitude slower than prior releases.  By getting rid of
a lot of unnecessary catalog updates, these changes buy back about a
factor of two (on my system).  The remaining overhead seems associated
with creating and deleting storage files, which we may not be able to
do much about without abandoning transaction safety for TRUNCATE.
This commit is contained in:
Tom Lane
2004-05-08 00:34:49 +00:00
parent 7c6baade7b
commit dd16b7aa9e
6 changed files with 161 additions and 262 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.118 2004/05/05 04:48:45 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.119 2004/05/08 00:34:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -826,7 +826,7 @@ ReindexTable(RangeVar *relation, bool force /* currently unused */ )
ReleaseSysCache(tuple);
if (!reindex_relation(heapOid))
if (!reindex_relation(heapOid, true))
ereport(NOTICE,
(errmsg("table \"%s\" has no indexes",
relation->relname)));
@ -936,7 +936,7 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */,
StartTransactionCommand();
SetQuerySnapshot(); /* might be needed for functions in
* indexes */
if (reindex_relation(relid))
if (reindex_relation(relid, true))
ereport(NOTICE,
(errmsg("table \"%s\" was reindexed",
get_rel_name(relid))));