I'm developing a very complex system, where in some cases I need to select only a few fields, a friend who has more experience in the area gave me some tips, but he did not explain why.
I have the following query that searches all users in random order, but I can never select the same user, here is my query : SELECT * FROM tabela ORDER BY RAND() LIMIT 1
Then my friend criticizes saying:
"You use RAND (), this scans the entire table to return a user only"
What did he mean by that?
The same also says:
"and never use a SELECT *"
Why?
Soon after he also says that:
"and you probably do not use indexes",
"You probably do not optimize my.cnf"
What did he mean? I asked him and he just ignored it, I searched the internet but I did not find anything about it.