Thanks very much. 2008/5/21 Paul McCullagh <[EMAIL PROTECTED]>:
> > On May 21, 2008, at 8:46 AM, Paul McCullagh wrote: > > On May 21, 2008, at 8:09 AM, Moon's Father wrote: >> >> Now I want to know which way you use to create index of a table. >>> 1、ix_u (item_id,item_count) >>> ix_item_count (item_count) >>> >> >> This makes sense if you have queries which search "item_id AND >> item_count", and queries which just search the column 'item_count'. >> > > On second thoughts, this answer is not complete. > > If this is case then the index ix_u (item_count, item_id) would be the best > choice. > > These indices: > > ix_u (item_id,item_count) > ix_item_count (item_count) > > are best when you have the following types of queries: > > WHERE item_id AND item_count ----> the server uses ix_u > (item_id,item_count) > WHERE item_id ----> the server uses ix_u > (item_id,item_count) > WHERE item_count ----> the server uses x_item_count > (item_count) > > > >> >> 2、ix_u (item_id,item_count) >>> ix_item_id (item_id) >>> >> >> This is duplication of the indexing of the column 'item_id'. The server is >> able to use the index ix_u (item_id,item_count) to search on the column >> 'item_id'. >> > > -- I'm a mysql DBA in china. More about me just visit here: http://yueliangdao0608.cublog.cn