Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary vs Integer - as primary key?

I was wondering if there are any obvious pros and cons one should be aware about, while choosing to use a Binary type as a primary key, while being RANDOMIZED.

Which means, new inserts will have random 4 bytes as their PK - versus having a sequence of type Integer?

I'm using MySQL/MyISAM.

Thanks, Doori Bar

like image 226
Doori Bar Avatar asked Oct 27 '25 23:10

Doori Bar


1 Answers

If the primary key isn't sequential then insert performance for a clustered index will not be very good. It has to rearrange the index for almost every insert.

like image 157
Jay Avatar answered Oct 30 '25 13:10

Jay