php - How would you optimize this sql query -


can me in optimizing query,

select a, b  tableaa  (c in (select d        tablebb        (e in (select f                 tablecc                 (g='$selected')                 )          )         ) ) , (g=$selected22) order a;  

whereas

tableaa : 1 million enteries

tablebb : 22 million enteries

tablecc : 79 million enteries

it works take time, 30 sec

is there other way right this?

the first step use join instead of nested queries:

select a, b tableaa join tablebb on c=d join tablecc on e=f g='$selected' order 

then make sure tables indexed correctly. it's better if c , d have same name, can use using (c) (and same e/f)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -