Re: How to Optimize distinct with index

2009-06-26 Thread Moon's Father
Hi. I think you should create an index like this. alter table user add index idx_tmp (key1,key2,key3,user_id) 2009/6/19 Darryle Steplight > Select user_id from user where key1=value and > key2=value2 and key3=value2 GROUP BY user_id > > is faster than > > > Select distinct user_id from user

Re: How to Optimize distinct with index

2009-06-19 Thread Darryle Steplight
Select user_id from user where key1=value and key2=value2 and key3=value2 GROUP BY user_id is faster than Select distinct user_id from user where key1=value and key2=value2 and key3=value2; 2009/6/18 周彦伟 : > Hi, >I have a sql : >Select distinct user_id from user where

Re: How to Optimize distinct with index

2009-06-18 Thread Dan Nelson
Please don't change the subject on someone else's thread. Next time, post a new message instead of hitting "reply" on an unrelated message. In the last episode (Jun 19): > Hi, > I have a sql : > Select distinct user_id from user where key1=value and > key2=value2 and key3=va