List:General Discussion« Previous MessageNext Message »
From:Darryle Steplight Date:June 15 2009 9:37am
Subject:Re: Fastest way to select on 0/1 flag
View as plain text  
Hi Artem,
     There can be many malicious factors at play here, but if you are
not using an index then definitely create on now. It will obviously
help you with option 1 and you can still benefit from it with option
2. If you don't have an index, MySQL has to search for you data row by
row which is much slower than using an index.

2009/6/15 Artem Kuchin <matrix@stripped>:
> Hello!
> I cannot figure out the fastest way to do a select on the floowing field:
> f_spec    tinyint not null;
> It is a table of 100 000 records of products and f_spec is set only for
> about 200 products.
> I figure it could be done in two ways:
> 1) create an index on f_spec and do simple
> select * from products where f_spec=1;
> 2) create a separate table
> create table specs (
>   product_id   int;
>   primary key (product_id)
> );
> then select ids from this table and join with the products table if needed.
> What is the best way?
> Also, it is often needed to know only the fact that there is any product
> with f_spec set.
> Is using index and doing
> select id from products where f_spec=1 limit 1
> will be very fast ?
> Regards,
> Artem
> --
> MySQL General Mailing List
> For list archives:
> To unsubscribe:

A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?
Fastest way to select on 0/1 flagArtem Kuchin15 Jun
  • Re: Fastest way to select on 0/1 flagDarryle Steplight15 Jun