database - How to get a mysql query to use a specific index? -


select * orders (index(idx)); 

when fired above query got error

mysql #1064 - have error in sql syntax

i have created index below

create index idx on orders(date,status); 

can tell me correct syntax?

if index appropriate used without explicitly specifying it.

given using select * not expect index used (even if index hint had correct syntax). choice down query optimiser's heuristics.

the correct syntax is:

select * orders use index(idx); 

ref: index hints

also, please note: 99 times out of 100, specifying index hint should not done. let optimiser job.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -