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
Post a Comment