On Mon, 30 Apr 2001, ryc wrote:

> I have a fairly large table (greater than 4mil rows) that I would to preform
> a query like:
> 
> SELECT col1,col2 FROM table WHERE a=1, c=2 ORDER BY b DESC LIMIT 50;
> 
> I have an index on the table INDEX1( a,b,c );
> 
> When running the query as is, it takes around 4seconds. If I omit the "DESC"
> part the query runs in a fraction of a second.
> 
> I would like the query to run faster when I use DESC. I looked at
> myisamchk -R to sort by the 'b' index but I want to be sure it will speed up
> my query since it may take a while to sort all 4million rows.

To improve things I'd suggest you drop the (a,b,c) index and create two new ones:
one on (a,c)
and another on (b)
and then do the myisamchk -R on the second index
You might also consider the --sort-records=# option

regards,
thalis


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to