MySQL的索引是什么?怎么优化?

  发布时间:2025-11-04 10:49:40   作者:玩站小弟   我要评论
复制CREATETABLE`user_info`( `id`BIGINT(20)NOTNULLAUTO_INCREMENT, `name`VARCHAR(5 。
MySQL的索引是什么?怎么优化?
复制CREATETABLE `user_info` (    `id`   BIGINT(20)  NOTNULL AUTO_INCREMENT,索引什优    `name` VARCHAR(50) NOTNULLDEFAULT,    `age`  INT(11)              DEFAULTNULL,    PRIMARYKEY (`id`),    KEY `name_index` (`name`)  )ENGINE = InnoDB DEFAULT CHARSET = utf8;  INSERTINTO user_info (name, age) VALUES (xys, 20);  INSERTINTO user_info (name, age) VALUES (a, 21);  INSERTINTO user_info (name, age) VALUES (b, 23);  INSERTINTO user_info (name, age) VALUES (c, 50);  INSERTINTO user_info (name, age) VALUES (d, 15);  INSERTINTO user_info (name, age) VALUES (e, 20);  INSERTINTO user_info (name, age) VALUES (f, 21);  INSERTINTO user_info (name, age) VALUES (g, 23);  INSERTINTO user_info (name, age) VALUES (h, 50);  INSERTINTO user_info (name, age) VALUES (i, 15);  CREATETABLE `order_info` (    `id`           BIGINT(20)  NOTNULL AUTO_INCREMENT,    `user_id`      BIGINT(20)           DEFAULTNULL,    `product_name` VARCHAR(50) NOTNULLDEFAULT,    `productor`    VARCHAR(30)          DEFAULTNULL,    PRIMARYKEY (`id`),    KEY `user_product_detail_index` (`user_id`, `product_name`, `productor`)  )ENGINE = InnoDB DEFAULT CHARSET = utf8;  INSERTINTO order_info (user_id, product_name, productor) VALUES (1, p1, WHH);  INSERTINTO order_info (user_id, product_name, productor) VALUES (1, p2, WL);  INSERTINTO order_info (user_id, product_name, productor) VALUES (1, p1, DX);  INSERTINTO order_info (user_id, product_name, productor) VALUES (2, p1, WHH);  INSERTINTO order_info (user_id, product_name, productor) VALUES (2, p5, WL);  INSERTINTO order_info (user_id, product_name, productor) VALUES (3, p3, MA);  INSERTINTO order_info (user_id, product_name, productor) VALUES (4, p1, WHH);  INSERTINTO order_info (user_id, product_name, productor) VALUES (6, p1, WHH);  INSERTINTO order_info (user_id, product_name, productor) VALUES (9, p8, TE);    1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.
  • Tag:

相关文章

最新评论