Skip to content
Advertisement

Optimizing mysql query for better performance to get low execution time

Currently I have this mysql query in my php code. I want to optimize it better because this query is currently inside a while loop and this query alone takes 25 seconds. so the bigger the loop the time it takes to execute this query over and over starts to become insane in only a short time. So I would love to get some help regarding this.

JavaScript

Edit

This is the sql query

JavaScript

And for the table site_details

JavaScript

Advertisement

Answer

Looks like

JavaScript

If the columns used in the conditions (IS_Nozzle, IS_Electronic_Components, etc.) are boolean columns (contains only 0 or 1) then = 1 may be removed.

PS. In the last case I’d recommend to use one column of SET datatype instead of a lot of separate columns.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement