Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL not using right index?

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

Got a bit of a weird one here :/

With this query:

Code:
EXPLAIN SELECT *
FROM Clients_Stats_Per_Click
WHERE (
client_click_date <=20100730
AND client_click_date >=20100713
)
AND click_processed =1
ORDER BY client_click_time DESC , client_click_date DESC , click_processed DESC
LIMIT 0 , 25

... it comes up with the following "key" set:

Code:
id  	 select_type  	 table  	 type  	 possible_keys  	 key  	 key_len  	 ref  	 rows  	 Extra
1 	SIMPLE 	Clients_Stats_Per_Click 	ref 	processed_text_ad_id,click_date_processed_detail_i... 	processed_text_ad_id 	4 	const 	30 	Using where; Using filesort

...as you can see, its coming up with the wrong index - processed_text_ad_id (this one is totally different, it holds "click_processed" and "client_click_text_ad_id_fk")

I definatly have the index set:

date_click_processed INDEX client_click_date, click_processed, client_click_time

Can anyone see what I'm doing wrong?

TIA

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top