DEV Community

Haseeb Ashraf
Haseeb Ashraf

Posted on

An Overview of Database Clusters, Databases, and Tables in PostgreSQL

In PostgreSQL, a database cluster is not a group of database servers but instead it is a single host that runs and looks after the database cluster as a whole.

The logical structure of a database cluster is such that it is a database object and these objects are logically separate from one another. All of the PostgreSQL database objects are internally managed by assigning each of them their own separate object identifiers (OIDs). These OIDs are 4-byte integers that help store the relation between database objects in proper system catalogs, based on the kind of object.

As for the physical structure, the database cluster is mainly a single directory known as a base directory which includes a few subdirectories and several files within the subdirectories. In this structure, a database is a subdirectory with the base directory as the root with each of the tables and indexes are a single file saved in the subdirectory of the database where it originally belongs.

A tablespace in in PostgreSQl is an extra space to store data outside the base directory. It is created where the directory is specified when the CREATE TABLESPACE statement is issued.

The internal layout of the Heap Table File is as follows:

  • Heap tuple(s)
    This is a record of the data. These tuples are stacked in such an order that they are from the bottom of the page.

  • Line pointer(s)
    This is a 4 byte long pointer that points to each head tuple.

  • Header data
    This is defined by the structure PageHeaderData and is assigned at the starting of the page.

In conclusion, this was a short overview of database clusters, databases, and tables in postgreSQL.

Top comments (0)