Any advantage of keeping the auto-magnification field in addition to the manual
I have the following db table:
`users`
- guid (UUID)
- username
- creation_data
Is there any advantage to keeping the auto-increment box here?
`users`
- id (autoincrement)
- guid
- username
- creation_date
Perhaps it would make someone else's key to the table more efficient or something else? What would be the pros and cons of keeping both fields (id and guid) versus one (guid)?
+3
source to share
2 answers
My advice is to get rid of the UUID field and only use it:
`users`
- id (autoincrement)
- username
- creation_date
This way, all foreign keys and indexes will be faster because all calculations and comparisons will be done using an integer instead of strings.
As a rough estimate, you can assume that an integer comparison requires a single CPU cycle, while it takes 20 cycles to compare a string with 20 characters.
0
source to share
Adding auto increment ID:
Benefits
- Not unless you need to know the order in which elements are inserted.
disadvantages
- More disk space
- If you want to add an index - large indexes (more memory usage, disk space)
- If you are going to set up replication, you will run into problems (some of the problems you may run into are listed here - http://dev.mysql.com/doc/refman/5.1/en/replication-features-auto-increment.html )
0
source to share