Hi,
I`m working on a huge DB, couple of million records. So Query optimization is very important. And I was wondering what is the fastest way to go.
Using alot of string funtions and 1 simple select, or use only 1 string function but 2 selects.
SImple Example to show what I`m talking about.
Because there are more WHERE clauses to use the indexes ect.
Code SQL:SELECT REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX())) AS 'column' REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX()))/200 AS 'result' FROM TABLE WHERE REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX())) > 1000 AND REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX()))/200 < 50 AND REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX()))/200 > 20
OR
Code SQL:SELECT `column`, `column`/200 AS 'result' FROM (SELECT REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX())) AS 'column' FROM TABLE ) AS temp WHERE `column` > 1000 AND `column`/200 < 50 AND `column`/200 > 20
Thanks for any reply![]()











Bookmarks