Index tells exactly in which page the data is present.
Index is also stored as pages in disk.
Each index for a primary key (ex) has pointer to the page in which the row is present in the heap.
In postgres, all secondary indexes point to the row_id.
Row vs Column Oriented Databases
Row-Oriented Database
Tables are stored as rows in disk
A single block io reads a single page which contains multiple rows.
Once we find a row, we get all the columns
Column-Oriented Database
Tables are stored as columns first in disk.
Each page will contain only a specific column
A single IO read to the table fetches multiple columns / pages with all matching rows
Mainly used for OLAP where aggregate functions are used mainly.
Each column's value for a row will be tagged along with its primary key. Ex: (firstname,id) , (lastname,id) where firstname and lastname are secondary columns and id is primary key.
Basically secondary indexes will point to row_id (in postgres). So upon reading a row, first we need to find row_id and then find the row using the row_id from the disk's pages.