How to Optimize distinct with index

周彦伟
2009-06-19T02:56:16+00:00

Hi,
	I have a sql : 
		Select distinct user-id from user where key1=value and
key2=value2 and key3=value2;

I add index on (key1,key2,key3,user-id), this sql use temporary table
howevery
I have thousands of queries per second.
How to optimize it?


Anthoer question:
Select * from user where user-id in(id1,id2,id3,id4,.....) order by use-id;
I add index on user-id,but after in,order use temporary table, How to
optimize it?

Thanks!

zhouyanwei




Loading


$ This page is proudly powered by www.pubbs.net, you can see more at mysql archive | Partners: ListWare Global Manufacturers