Introduce the concept of relation forks. An smgr relation can now consist
[PostgreSQL.git] / src / backend / storage / smgr / README
blob48487bf4f83f6980fc2e4506b75ef5ae07e616d5
1 $PostgreSQL$
3 Storage Manager
4 ===============
6 In the original Berkeley Postgres system, there were several storage managers,
7 of which only the "magnetic disk" manager remains.  (At Berkeley there were
8 also managers for the Sony WORM optical disk jukebox and persistent main
9 memory, but these were never supported in any externally released Postgres,
10 nor in any version of PostgreSQL.)  However, we retain the notion of a storage
11 manager switch in case anyone wants to reintroduce other kinds of storage
12 managers.
14 In Berkeley Postgres each relation was tagged with the ID of the storage
15 manager to use for it.  This is gone.  It would be more reasonable to
16 associate storage managers with tablespaces (a feature not present as this
17 text is being written, but one likely to emerge soon).
19 The files in this directory, and their contents, are
21     smgrtype.c  Storage manager type -- maps string names to storage manager
22                 IDs and provides simple comparison operators.  This is the
23                 regproc support for type 'smgr' in the system catalogs.
24                 (This is vestigial since no columns of type smgr exist
25                 in the catalogs anymore.)
27     smgr.c      The storage manager switch dispatch code.  The routines in
28                 this file call the appropriate storage manager to do hardware
29                 accesses requested by the backend.  smgr.c also manages the
30                 file handle cache (SMgrRelation table).
32     md.c        The magnetic disk storage manager.
34 Note that md.c in turn relies on src/backend/storage/file/fd.c.
36 Relation Forks
37 ==============
39 Since 8.4, a single smgr relation can be comprised of multiple physical
40 files, called relation forks. This allows storing additional metadata like
41 Free Space information in additional forks, which can be grown and truncated
42 independently of the main data file, while still treating it all as a single
43 physical relation in system catalogs.
45 It is assumed that the main fork, fork number 0 or MAIN_FORKNUM, always
46 exists. Fork numbers are assigned in src/include/storage/relfilenode.h.
47 Functions in smgr.c and md.c take an extra fork number argument, in addition
48 to relfilenode and block number, to identify which relation fork you want to
49 access. Since most code wants to access the main fork, a shortcut version of
50 ReadBuffer that accesses MAIN_FORKNUM is provided in the buffer manager for
51 convenience.