Postgresql – Query performance with primary keys of different data types

postgresql

Is there a significant difference in performance if i decide to use INT or BIGINT as data type of a primary key in a table? Of course if i use BIGINT the value will have twice it's size. But as the primary key has always an index to speed up queries, is there going to be a significant difference in performance?

Best Answer

i would not see this as a major issue. of course things are a little larger but if we talk about a single integer column things will most likely be lost in noise anyway. we got 24 bytes of tuple header ... then comes the data. if things are 4 bytes larger? what difference does it make in a 10 column table.

so, no worries ... make sure that you do what is good for your app.