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


Adding auto increment ID:

Benefits

  • Not unless you need to know the order in which elements are inserted.


disadvantages

0


source







All Articles