开发者

Mysql (innodb) index decision for better perfomence

开发者 https://www.devze.com 2023-04-09 20:10 出处:网络
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.

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

精彩评论

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