Efficiency of table with multiple columns as primary key or ID

Is it more efficient to have:

  • combination of two or more columns as a primary key

  • have an ID as primary key

I am assuming that having the ID as primary key is more efficient, but is it more ‘correct’ to use the more columns as primary key if they are going to be always unique?

It’s alright either way. One thing is that Yii’s GridView is optimized to work with a single column PK.

1 Like