MySQL Forums
Forum List  »  Optimizer & Parser

Re: Golden Rules of writting efficient query
Posted by: KimSeong Loh
Date: November 23, 2006 02:17AM

> - Mysql use only one index for any query
MySQL uses 1 index for each table access, but in MySQL 5.0 it can use more than 1 index

> - avoid use of LIMIT
LIMIT is fine if used appropriately

> - use count(*) instead of count(field_name)
This 2 has different meaning in some situation

> - If WHERE is like "WHERE A = 200 OR B >1000" ,
> to optimize such query split query with UNION i.e
>
> "SELECT SOME_FIELDS FROM SOME_TABLE WHERE A =
> 200 UNION "SELECT * FROM SOME_TABLE WHERE B
> >1000" AND create separate index on field "A" and
> "B".
MySQL 5.0 may be able to use index merge optimization on this, but I am not so sure with the > , if both are = then it will.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Golden Rules of writting efficient query
3340
November 23, 2006 02:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.