IamIC
IamIC

Reputation: 18249

How do PostgreSQL indexes reference rows?

Do indexes in PG store some type of row internal ID, or store the row's primary key?

I am deducing it must be an internal row ID since tables don't have to have PK's. However, I can't find a specific answer to this question.

Upvotes: 6

Views: 1935

Answers (1)

user330315
user330315

Reputation:

Each row has an internal "address" stored in the system column ctid (very similar to Oracle's rowid). This ctid value is stored in the index.

More details are in the manual:

You can select the column if you want:

select ctid, t.*
from your_table t;

Upvotes: 4

Related Questions