Don't forget to run "optimize table" after you build
the combined index or make significant changes.
  -- Greg

PS: Sorry to hear of MySQL's "gender issues" ;-)

On Mon, Jan 19, 2004 at 10:20:12AM -0500, Balazs Rauznitz wrote:
> 
> I saw surprisingly slow query results on columns that were indexed.
> 
> Here's the table definition:
> 
> create table sex (
> id integer,
> sex char(1));
> create index id_index on sex (id);
> create index sex_index on sex (sex);
> 
> Then I loaded a million rows, id was from 1 to 1_000_000, sex was 
> randomly 'F' or 'M'.
> 
> When searching on 'id' everything is snappy:
> 
> mysql> select count(*) from sex where id>459000 and id <=460000;
> +----------+
> | count(*) |
> +----------+
> |     1000 |
> +----------+
> 1 row in set (0.00 sec)
> 
> However when the 'sex' column is involved:
> 
> mysql> select count(*) from sex where id>459000 and id <=460000 and sex = 'M';
> +----------+
> | count(*) |
> +----------+
> |      504 |
> +----------+
> 1 row in set (5.09 sec)
> 
> Any way to make this faster ?
> 
> <Insert jokes about sex making MySQL slow here>
> 
> I'm running MySQL 4.0.16 on a 1GHz AMD CPU under linux.
> 
> Thanks,
> 
> Balazs

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to