开发者

Mysql (innodb) index decision for better perfomence

I have a simple table with 1,000,000 rows.

this row has a datetime field that I am always quering where statement on it.

SELECT * from my_table WHERE date_t开发者_开发技巧ime = 'blabla';

Is it reccomened to put index on it for that reason only (where statement)?


Definitely yes. Without it, MySQL will have to do a full table scan (go row by row comparing the date_time to the provided value.)


Yes, put an index on fields in the where clause.

Just take a look at the EXPLAIN EXTENDED (put it in front of your query) and see what the query actually touches.

Also note: Do not use SELECT *, but always the fields you actually use

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜