How to hint the index to use in a MySQL select query?

匆匆过客 提交于 2019-11-28 22:34:09

You missed the FROM table

Correct SQL should be:

SELECT art.firma FROM your_table USE INDEX (i_iln) WHERE ....

Markus Mikkolainen
select * from table use index (idx);

http://dev.mysql.com/doc/refman/5.0/en/index-hints.html

sometimes, with use index (index_name) optimizer might go for table scan, if you use hint force index, optimizer will be forced to use index, will go for table scan only if no ways left to get the rows with provided index.

SELECT art.firma FROM art FORCE INDEX (i_iln);

for more detail on hints USE INDEX and FORCE INDEX check this link

Select Coloumn1,Coloumn2,Coloumn.... FROM TABLE_NAME USE INDEX(index_name) WHERE Coloumn="condition";

if you have correct index thn you dnt need to use index(). your query automic select correct index.If your query slow after using index thn recheck your index ,something wrong in index. thanks in advance.enter code here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!