Where and how PostgreSQL store your data on disk?

In short, your data is simply stored in a set of files on disk.

In PostgreSQL, these files are store in a directory called base (Path: /database/base). There are many subdirectories in the base directory where names are just numbers (which are object_id). Each numbered directory is mapped with a single database. You can run the following command to know which directory number relates to which database:

SELECT oid as object_id, datname as database_name FROM pg_database;

Here is the output example:

object_id | database_name
    ..... | ......
    19044 | sample

If you have a look at the data in the "sample" database (which has an OID of 19044), which path is /database/base/19044, you will see many files which are divide exactly by 8192 (8k). This is because PostgreSQL (by default) writes blocks of data (pages) to disk in 8k chunks. If you have a large table, you will see multiple files with the same number appended with .1, .2, .3, and so on [1]. 


[1] https://www.postgresql.fastware.com/blog/where-and-how-is-your-data-actually-stored-on-disk