hi all,
i was working with some code last night, and one of my queries was a select statement joining two tables with an order by clause on two fields and a limit, e.g.
there were around 150,000 records total in foo table, and this query was taking 13 seconds on average to execute. i built indexes on every field with no improvement.
then some thought occurred to me, and i tried
lo and behold, it executed in about 2 seconds, and the order and offset still worked properly!
anyone see any potential problems with this method?
thought i'd share
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
i was working with some code last night, and one of my queries was a select statement joining two tables with an order by clause on two fields and a limit, e.g.
Code:
select
foo,
bar
from
foos
inner join bars
on foos.id = bars.foos_id
where
condition = met
order by
foo,
bar
limit 350, 50
then some thought occurred to me, and i tried
Code:
[b]
select *
from ([/b]
select
foo,
bar
from
foos
inner join bars
on foos.id = bars.foos_id
where
condition = met[b]
) wrapper
order by
foo,
bar
limit 350, 50[/b]
lo and behold, it executed in about 2 seconds, and the order and offset still worked properly!
anyone see any potential problems with this method?
thought i'd share
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big