List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:June 29 2001 7:08pm
Subject:Re: distinct / limit optimization
View as plain text  
Because it wasn't in system cache yet?

X Gogo wrote:

> Hi,
> 
> I've tried the folowing query:
>     SELECT DISTINCT column1 FROM table1 LIMIT 10;
> and got the result for 0.23 sec.
> Then I've tried the same query without limit:
>     SELECT DISTINCT column1 FROM table1;
> and got the result for 0.01 sec. which is some 23 times
> faster. There are about 10000 rows in table1 and column1
> has an index. I've read in the manual that MySQL uses optimization when you 
> combine DISTINCT with LIMIT n that would make it stop as soon as it finds n 
> unique rows.
> Why then the first query that uses LIMIT is considerably slower?
> 
> George
> ----
> Безплатна пощенска служба http://mail.Rambler.bg/
> 
> ---------------------------------------------------------------------
> 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 <mysql-thread78055@stripped>
> To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Gerald L. Clark
gerald_clark@stripped

Thread
distinct / limit optimizationX Gogo29 Jun
  • Re: distinct / limit optimizationGerald Clark29 Jun