mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Clean up code associated with updating pg_class statistics columns
(relpages/reltuples). To do this, create formal support in heapam.c for "overwrite" tuple updates (including xlog replay capability) and use that instead of the ad-hoc overwrites we'd been using in VACUUM and CREATE INDEX. Take the responsibility for updating stats during CREATE INDEX out of the individual index AMs, and do it where it belongs, in catalog/index.c. Aside from being more modular, this avoids having to update the same tuple twice in some paths through CREATE INDEX. It's probably not measurably faster, but for sure it's a lot cleaner than before.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.214 2006/04/04 19:35:33 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.215 2006/05/10 23:18:39 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1173,11 +1173,12 @@ AddStr(char *str, int strlength, int mderef)
|
||||
* index_register() -- record an index that has been set up for building
|
||||
* later.
|
||||
*
|
||||
* At bootstrap time, we define a bunch of indices on system catalogs.
|
||||
* We postpone actually building the indices until just before we're
|
||||
* finished with initialization, however. This is because more classes
|
||||
* and indices may be defined, and we want to be sure that all of them
|
||||
* are present in the index.
|
||||
* At bootstrap time, we define a bunch of indexes on system catalogs.
|
||||
* We postpone actually building the indexes until just before we're
|
||||
* finished with initialization, however. This is because the indexes
|
||||
* themselves have catalog entries, and those have to be included in the
|
||||
* indexes on those catalogs. Doing it in two phases is the simplest
|
||||
* way of making sure the indexes have the right contents at the end.
|
||||
*/
|
||||
void
|
||||
index_register(Oid heap,
|
||||
@ -1189,7 +1190,7 @@ index_register(Oid heap,
|
||||
|
||||
/*
|
||||
* XXX mao 10/31/92 -- don't gc index reldescs, associated info at
|
||||
* bootstrap time. we'll declare the indices now, but want to create them
|
||||
* bootstrap time. we'll declare the indexes now, but want to create them
|
||||
* later.
|
||||
*/
|
||||
|
||||
@ -1223,6 +1224,10 @@ index_register(Oid heap,
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* build_indices -- fill in all the indexes registered earlier
|
||||
*/
|
||||
void
|
||||
build_indices(void)
|
||||
{
|
||||
@ -1233,13 +1238,10 @@ build_indices(void)
|
||||
|
||||
heap = heap_open(ILHead->il_heap, NoLock);
|
||||
ind = index_open(ILHead->il_ind);
|
||||
index_build(heap, ind, ILHead->il_info);
|
||||
|
||||
/*
|
||||
* In normal processing mode, index_build would close the heap and
|
||||
* index, but in bootstrap mode it will not.
|
||||
*/
|
||||
index_build(heap, ind, ILHead->il_info, false, false);
|
||||
|
||||
/* XXX Probably we ought to close the heap and index here? */
|
||||
index_close(ind);
|
||||
heap_close(heap, NoLock);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user