Reputation: 3780
I would like to know how or how much can affect the performance of the server when I use UUID for my primary keys in MySQL.
Upvotes: 1
Views: 1870
Reputation: 2084
I suppose you are using InnoDB (You should anyway....)
So read the following chapter from High performance MySQL 2ed, p.117: http://books.google.com.hk/books?id=BL0NNoFPuAQC&lpg=PA117&ots=COPMBsvA7V&dq=uuid%20innodb%20clustered%20index%20high%20performance%20mysql&pg=PA117#v=onepage&q&f=false
In general, UUID is a poor choice from the performance standpoint (due to clustered index) and they have a benchmark to prove this.
Upvotes: 2
Reputation: 5609
UUID is 36 chars long, which means 36 bytes. INT is 4 bytes with variations of TINYINT, MEDIUMINT and BIGINT, which are all below 36 bytes.
Therefore, for each record you insert, your index will allocate more space. Also, UUID is taking more time to be computed opposing to incrementing integer.
As for how much it can affect the system, it's hard to give out the actual numbers because there are various factors - the load of the system, the hardware and so on.
Upvotes: 1