Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
Essentially I think the problem is this... I am trying to do an ORDER BY on a pre-populated (and indexed) column called random_number... I created this column because RAND() is so slow... It is the ORDER BY which is causing all the slow downs... If I do a select without the order by it is

Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
Really what I need to do is "re-order" the database rows (for good) by the random_number column... note.. I am not using RAND() at all... Hey, this gives me an idea... Given I have price ranges 1-2, 2-5, 5-10 etc... and the prices are all like 1.99, 1.96 etc... What if I precalculate a value

Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
On 18 Nov 2006, at 19:35, Jeremy Dunck wrote: > This isn't a Django question, but indexes only work well when there's > a large distribution of values. If lots of your products are in that > price range, you're still ordering by loads of randoms. Try assigning > (as a column value) a random int

Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
On 18 Nov 2006, at 18:59, tonemcd wrote: > > Perhaps something from here will help? > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59883 > > Where your list is an xrange(min...max) of id's from your database > table. That is, do it in python, not with your database... Ah sorry, for

Re: Database optmization guru needed...

2006-11-18 Thread Jay Klehr
Tom Smith wrote: > Hello. > > When in mysql I do a... > > explain select title from burningahole_product where ( price >10 and > price<20) order by random_number limit 10; > > > ... I get... > > ++-+--+--- > ++-

Re: Database optmization guru needed...

2006-11-18 Thread Jeremy Dunck
On 11/18/06, Tom Smith <[EMAIL PROTECTED]> wrote: > > Hello. > > When in mysql I do a... > > explain select title from burningahole_product where ( price >10 and > price<20) order by random_number limit 10; This isn't a Django question, but indexes only work well when there's a large distribution

Re: Database optmization guru needed...

2006-11-18 Thread tonemcd
Perhaps something from here will help? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59883 Where your list is an xrange(min...max) of id's from your database table. That is, do it in python, not with your database... Or maybe this, http://www.petefreitag.com/item/466.cfm - which *does