AUTO_INCREMENT ON the MyISAM STORAGE ENGINE
AUTO_INCREMENT ON the MyISAM STORAGE ENGINE
CASE:
HOW TO TUNNING AUTO_INCREMENT ON THE MyIS STORAGE ENGINE
SOLVE:
1.AUTO_INCREMENT column is a multiple-column index and order by last column of a multiple-column index.
2.AUTO_INCREMENT column is one key faster in engine myisam than engine innodb
1.AUTO_INCREMENT column is a multiple-column index and order by last column of a multiple-column index.
mysql> create table autoincre_demo
-> (
-> d1 smallint not null auto_increment,
-> d2 smallint not null,
-> name varchar(10),
-> primary key (d2,d1)
-> )
-> engine=myisam;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into autoincre_demo(d2,name) values(2,'2'),(3,'3'),(4,'4'),(2,'2'),(3,'3'),(4,'4');
Query OK, 6 rows affected (0.00 sec)
Records: 6 Duplicates: 0 Warnings: 0
mysql> select * from autoincre_demo;
+----+----+------+
| d1 | d2 | name |
+----+----+------+
| 1 | 2 | 2 |
| 1 | 3 | 3 |
| 1 | 4 | 4 |
| 2 | 2 | 2 |
| 2 | 3 | 3 |
| 2 | 4 | 4 |
+----+----+------+
6 rows in set (0.00 sec)
## order by id2 and id2 is last column of a multiple-column index
2.AUTO_INCREMENT column is one key faster in engine myisam than engine innodb
mysql> create table myisam_tab
-> (
-> id MEDIUMINT NOT NULL AUTO_INCREMENT,
-> id2 MEDIUMINT NOT NULL,
-> PRIMARY KEY(ID)
-> )
-> engine=MYISAM;
Query OK, 0 rows affected (0.01 sec)
mysql> create table innodb_tab
-> (
-> id MEDIUMINT NOT NULL AUTO_INCREMENT,
-> id2 MEDIUMINT NOT NULL,
-> PRIMARY KEY(ID)
-> )
-> engine=innodb;
Query OK, 0 rows affected (0.04 sec)
mysql> insert into myisam_tab(id2) select id2 from myisam_tab;
Query OK, 409600 rows affected (1.10 sec)
Records: 409600 Duplicates: 0 Warnings: 0
mysql> insert into innodb_tab(id2) select id2 from innodb_tab;
Query OK, 409600 rows affected (4.22 sec)
Records: 409600 Duplicates: 0 Warnings: 0
## insert into myisam_tab time is 1.10 sec and insert into innodb_tab time is 4.22 sec
Reference
http://dev.mysql.com/doc/refman/5.7/en/myisam-storage-engine.html
When rows are
inserted in sorted order (as when you are using an
AUTO_INCREMENT column), the index tree is split so that the high node only contains one key. This
improves space utilization in the index tree.
Internal handling of one AUTO_INCREMENT column per table is supported. MyISAM automatically updates this column for INSERT and UPDATE operations. This makes AUTO_INCREMENT columns faster (at least 10%). Values at the top of the sequence are not reused after being deleted. (When an AUTO_INCREMENT column is defined as the last column of a multiple-column index, reuse of values deleted from the top of a sequence does occur.) The AUTO_INCREMENT value can be reset with ALTER TABLE or myisamchk.
########################################################################################
版權所有,文章允許轉載,但必須以連結方式註明源地址,否則追究法律責任!【QQ交流群:53993419】
QQ:14040928 E-mail:dbadoudou@163.com
本文連結: http://blog.itpub.net/blog/post/id/2072782/
########################################################################################
dbadoudou scripts
create table autoincre_demo
(
d1 smallint not null auto_increment,
d2 smallint not null,
name varchar(10),
primary key (d2,d1)
)
engine=myisam;
insert into autoincre_demo(d2,name) values(2,'2'),(3,'3'),(4,'4'),(2,'2'),(3,'3'),(4,'4');
select * from autoincre_demo;
create table myisam_tab
(
id MEDIUMINT NOT NULL AUTO_INCREMENT,
id2 MEDIUMINT NOT NULL,
PRIMARY KEY(ID)
)
engine=MYISAM;
create table innodb_tab
(
id MEDIUMINT NOT NULL AUTO_INCREMENT,
id2 MEDIUMINT NOT NULL,
PRIMARY KEY(ID)
)
engine=innodb;
insert into myisam_tab(id2) select id2 from myisam_tab;
insert into innodb_tab(id2) select id2 from innodb_tab;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-2072782/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL:ERROR 1286 (42000): Unknown storage engine 'MyISAM'MySqlError
- Failed to read auto-increment value from storage engineAIREM
- 解決ERROR 1030 (HY000): Got error 168 from storage engine apparmorErrorGoAPP
- SQL基礎 AUTO_INCREMENT 欄位SQLREM
- MySQL5.7之auto_increment回溯MySqlREM
- mysql中auto_increment是什麼MySqlREM
- MyISAM InnoDB 區別
- storage事件中的坑,storage.setItem()無法觸發storage事件事件
- Azure Storage 系列(六)使用Azure Queue Storage
- Azure Storage 系列(七)使用Azure File Storage
- Local Storage
- gin.engine
- mysql myisam的鎖機制MySql
- Azure Storage 系列(四)在.Net 上使用Table Storage
- JavaScript storage 事件JavaScript事件
- Web Storage概述Web
- Password Storage - UserDetailsAI
- MySQL 序列 AUTO_INCREMENT詳解及例項程式碼MySqlREM
- fio: engine libaio not loadableAI
- AIRVPS WEB APP ENGINEAIWebAPP
- 安裝 Docker EngineDocker
- VBScript Scripting Engine初探
- Mysql auto_increment 重新計數(讓id從1開始)MySqlREM
- Docker storage儲存Docker
- cookie、session、web storageCookieSessionWeb
- ASM(Automatic Storage Management)ASM
- 探究Flutter Engine除錯Flutter除錯
- Flutter Engine環境搭建Flutter
- Mysql 中 MyISAM 和 InnoDB 的區別MySql
- SAP WM Storage Type Search配置裡的Storage Class & WPC標記
- SAP 電商雲 Spartacus UI SSR 裡 engine 和 engine instance 的區別UI
- MySQL 主從 AUTO_INCREMENT 不一致問題分析MySqlREM
- MySQL儲存引擎--MyISAM與InnoDB區別MySql儲存引擎
- Mysql中的鎖機制——MyISAM表鎖MySql
- MySQL MyISAM引擎的讀鎖與寫鎖MySql
- 【ionic】storage本地快取快取
- Automatic Storage Management (ASM)(轉)ASM
- [Vue] Provide and Inject Global StorageVueIDE
- engine.io 原理詳解