Tips to optimize Select in SQL. Does the conditional order in Where matter?

Asked

Viewed 66 times

2

Do you have any tips for optimizing Select in sql? If I search a table with over 500,000 or 1 million records, is there any way to optimize my search so that it doesn’t spend too much server resources and doesn’t take too long?

Does the order that I place the conditionals after the WHERE make any difference? For example, if I put first Idusuario=$idusuario (this would reduce the records enough), and then put Value>50. Would this be better than putting Value>50 first (which would still generate many records) and then Idusuario=$idusuario? Or it makes no difference the order that is placed the conditional?

Anyway, if anyone can give some tips on how to optimize, I would really appreciate it! Including in table type, use Myisam or Innodb in BD Mysql. Thank you!

  • Create indices to optimize the search. A tip would be to use the Oracle or SQL-Server tools to optimize your select. They suggest the creation of missing indices. The order of the columns in the WHERE clause does not matter.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.