Re: Golden Rules of writting efficient query
> - 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.
Subject
Views
Written By
Posted
8920
November 23, 2006 01:37AM
Re: Golden Rules of writting efficient query
3340
November 23, 2006 02:17AM
2533
December 08, 2006 08:28AM
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.