In this blog, I will give a brief description about what is database cluster, database and tables in postgres and what are their internal structures.
Database cluster is a collection of databases that is managed with the help of postgres server. This server runs on a single host and provides services to single database cluster.
A paradoxical point that should be kept in mind while working with postgres must be pointed. In postgres, databases are considered as database objects just like the other objects in a database like tables, functions et cetra.
In a database a base directory is formed in which all the information about database is stored. Below Image will give a better idea about this:
A database is a _sub-directory _that is present under the base directory.
Table space is an additional area outside the base directory that stores the information about particular data.
When CREATE TABLESPACE command is provided, a tablespace is formed outside the base directory.
A heap data file that stores the actual data is present inside the tablespace.
Now we will look at the structure of heap data file to get better understanding.
The data file is divided into pages of fixed size. These pages are numbered from 0 to n and these numbers are called block numbers.
A page within a table comprises of three kinds of data:
Heap Tuple that stores the data.
Line pointers of length 4 byte and points to each heap tuple
A **header data **is allocated in the beginning of each page.
Basic Methods to Read and Write Tuples
For Writing Heap Tuples:
This here summarizes the basic structure of databases in post gres. If you want an in depth analysis please go through the article provided below. Thanks:
Top comments (0)