In MySQL, is it generally a good idea to always do a COUNT(*) first to determine if you should do a SELECT * to actually fetch the rows, or is it better to just do the SELECT * directly and then check if it returned any rows?
In MySQL, is it generally a good idea to always do a COUNT(*) first
Share
Unless you lock the table/s in question, doing a
select count(*)is useless. Consider:Process 1:
Process 2:
Process 1:
Of course, locking a table is not a very good idea in a server environment.