PostgreSQL primary key length limit

FolksLord picture FolksLord · Dec 27, 2010 · Viewed 9.9k times · Source

What is the limit of the length of primary key column? I'm going to use varchar as primary key. I've found no info, how long it can be, since PostgreSQL does not require to specify varchar limit when used as primary key?

Answer

Peter Eisentraut picture Peter Eisentraut · Dec 27, 2010

The maximum length for a value in a B-tree index, which includes primary keys, is one third of the size of a buffer page, by default floor(8192/3) = 2730 bytes.