Home > Enterprise >  What is the maximum number of columns that can make up a primary key in PostgreSQL
What is the maximum number of columns that can make up a primary key in PostgreSQL

Time:12-07

In SQL Server, mySQL, its 16. In postgres, its greater but I cannot find any documentation.

I created a table with 20 columns as the PK and it worked fine. Curious what is the max?

CodePudding user response:

As documented in the manual

columns per index 32

However, this is only part of the truth.

There is also a limit on the maximum size of an index entry which a bit under 1/3 of the block size.

The default block size is 8192 bytes, so the sum of all column values cannot exceed roughly 2700 bytes in an index

  • Related