77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.59 1999/02/21 03:49:36 scrappy Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.60 1999/05/01 19:09:44 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
7777#include "utils/memutils.h"
7878#include "utils/rel.h"
7979#include "utils/relcache.h"
80- #include "utils/relcache.h"
8180#include "utils/syscache.h"
8281
8382
@@ -87,13 +86,6 @@ static Relation RelationNameCacheGetRelation(char *relationName);
8786static void init_irels (void );
8887static void write_irels (void );
8988
90- /* ----------------
91- *defines
92- * ----------------
93- */
94- #define private static
95- #define INIT_FILENAME "pg_internal.init"
96-
9789/* ----------------
9890 *externs
9991 * ----------------
@@ -1826,11 +1818,20 @@ RelCheckFetch(Relation relation)
18261818 * from an initialization file in the data/base/... directory.
18271819 *
18281820 * + If the initialization file isn't there, then we create the
1829- * relationdescriptor using sequential scans and writeit to
1821+ * relationdescriptors using sequential scans and write'em to
18301822 * the initialization file for use by subsequent backends.
18311823 *
1832- *This is complicated and interferes with system changes, but
1833- *performance is so bad that we're willing to pay the tax.
1824+ *We could dispense with the initialization file and just build the
1825+ *critical reldescs the hard way on every backend startup, but that
1826+ *slows down backend startup noticeably if pg_class is large.
1827+ *
1828+ *As of v6.5, vacuum.c deletes the initialization file at completion
1829+ *of a VACUUM, so that it will be rebuilt at the next backend startup.
1830+ *This ensures that vacuum-collected stats for the system indexes
1831+ *will eventually get used by the optimizer --- otherwise the relcache
1832+ *entries for these indexes will show zero sizes forever, since the
1833+ *relcache entries are pinned in memory and will never be reloaded
1834+ *from pg_class.
18341835 */
18351836
18361837/* pg_attnumind, pg_classnameind, pg_classoidind */
@@ -1852,9 +1853,9 @@ init_irels(void)
18521853int relno ;
18531854
18541855#ifndef __CYGWIN32__
1855- if ((fd = FileNameOpenFile (INIT_FILENAME ,O_RDONLY ,0600 ))< 0 )
1856+ if ((fd = FileNameOpenFile (RELCACHE_INIT_FILENAME ,O_RDONLY ,0600 ))< 0 )
18561857#else
1857- if ((fd = FileNameOpenFile (INIT_FILENAME ,O_RDONLY |O_BINARY ,0600 ))< 0 )
1858+ if ((fd = FileNameOpenFile (RELCACHE_INIT_FILENAME ,O_RDONLY |O_BINARY ,0600 ))< 0 )
18581859#endif
18591860{
18601861write_irels ();
@@ -2017,12 +2018,12 @@ write_irels(void)
20172018RelationBuildDescInfo bi ;
20182019
20192020#ifndef __CYGWIN32__
2020- fd = FileNameOpenFile (INIT_FILENAME ,O_WRONLY |O_CREAT |O_TRUNC ,0600 );
2021+ fd = FileNameOpenFile (RELCACHE_INIT_FILENAME ,O_WRONLY |O_CREAT |O_TRUNC ,0600 );
20212022#else
2022- fd = FileNameOpenFile (INIT_FILENAME ,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY ,0600 );
2023+ fd = FileNameOpenFile (RELCACHE_INIT_FILENAME ,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY ,0600 );
20232024#endif
20242025if (fd < 0 )
2025- elog (FATAL ,"cannot create init file %s" ,INIT_FILENAME );
2026+ elog (FATAL ,"cannot create init file %s" ,RELCACHE_INIT_FILENAME );
20262027
20272028FileSeek (fd ,0L ,SEEK_SET );
20282029