Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL auto_increment vs max

Tags:

sql

mysql

Alright, which is faster and better to use?

Auto_increment

or

Call an sql which which does a max and then add one

So ultimately the question is should you use mysql to do it or do it yourself?

like image 752
David Avatar asked Dec 31 '25 20:12

David


1 Answers

Definitely auto-increment. The SQL you would write is not thread-safe, and would only apply to the data that enters through your specific stored procedure/sql.

like image 95
Erich Avatar answered Jan 02 '26 10:01

Erich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!