How MySQL Uses Indexes CREATE INDEX SELECT COUNT(*)

 

 

 

 

 

 

 

 

 

 

MySQL :: MySQL 5.7 Reference Manual :: 9.3.1 How MySQL Uses Indexes
https://dev.mysql.com/doc/refman/5.7/en/mysql-indexes.html

 

 

 CREATE INDEX   SELECT COUNT(*)

 

CREATE INDEX windex_countrycode ON sales_rank (countrycode);
CREATE INDEX windex_grab_amz_date ON sales_rank (grab_amz_date);
CREATE INDEX windex_categoryid ON sales_rank (categoryid);
CREATE INDEX windex_grab_rank ON sales_rank (grab_rank);

[SQL]
CREATE INDEX windex_countrycode ON sales_rank (countrycode);
受影响的行: 1150091
时间: 36.351s

[SQL]
CREATE INDEX windex_grab_amz_date ON sales_rank (grab_amz_date);
受影响的行: 1150091
时间: 37.230s

[SQL]
CREATE INDEX windex_categoryid ON sales_rank (categoryid);
受影响的行: 1150091
时间: 41.205s

[SQL]
CREATE INDEX windex_grab_rank ON sales_rank (grab_rank);
受影响的行: 1150091
时间: 42.972s


ALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 42.791s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 42.540s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 40.466s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 36.134s

 

 

 

 

 

SELECT COUNT(*) FROM sales_rank;

1150091

CREATE INDEX windex_countrycode ON sales_rank (countrycode);
CREATE INDEX windex_grab_amz_date ON sales_rank (grab_amz_date);
CREATE INDEX windex_categoryid ON sales_rank (categoryid);
CREATE INDEX windex_grab_rank ON sales_rank (grab_rank);

[SQL]
CREATE INDEX windex_countrycode ON sales_rank (countrycode);
受影响的行: 1150091
时间: 38.098s

[SQL]
CREATE INDEX windex_grab_amz_date ON sales_rank (grab_amz_date);
受影响的行: 1150091
时间: 39.191s

[SQL]
CREATE INDEX windex_categoryid ON sales_rank (categoryid);
受影响的行: 1150091
时间: 38.382s

[SQL]
CREATE INDEX windex_grab_rank ON sales_rank (grab_rank);
受影响的行: 1150091
时间: 39.717s

 

ALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 40.228s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 37.649s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.389s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.135s

 

CREATE INDEX windex_countrycode ON sales_rank (countrycode);
CREATE INDEX windex_grab_amz_date ON sales_rank (grab_amz_date);
CREATE INDEX windex_categoryid ON sales_rank (categoryid);
CREATE INDEX windex_grab_rank ON sales_rank (grab_rank);

[SQL]
CREATE INDEX windex_countrycode ON sales_rank (countrycode);
受影响的行: 1150091
时间: 36.486s

[SQL]
CREATE INDEX windex_grab_amz_date ON sales_rank (grab_amz_date);
受影响的行: 1150091
时间: 39.930s

[SQL]
CREATE INDEX windex_categoryid ON sales_rank (categoryid);
受影响的行: 1150091
时间: 40.498s

[SQL]
CREATE INDEX windex_grab_rank ON sales_rank (grab_rank);
受影响的行: 1150091
时间: 40.745s

 

ALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251sALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251sALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251sALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251sALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251sALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251sALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251sALTER TABLE sales_rank DROP INDEX windex_countrycode;
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_countrycode;
受影响的行: 1150091
时间: 41.601s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_amz_date;
受影响的行: 1150091
时间: 39.273s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_categoryid;
受影响的行: 1150091
时间: 36.664s

[SQL]
ALTER TABLE sales_rank DROP INDEX windex_grab_rank;
受影响的行: 1150091
时间: 35.251s

 

posted @ 2016-12-20 17:14  papering  阅读(219)  评论(0编辑  收藏  举报