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
Post a Comment