MYSQL TABLE CHANGE STORAGE ENGINE
MYSQL TABLE CHANGE STORAGE ENGINE
1.create table and set storage engine
CREATE TABLE `doudou01` (
`i` bigint(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`i`)
)
ENGINE=MyISAM DEFAULT CHARSET=gbk;
## default storage engine is innodb
## check table status
mysql>
show table status like 'doudou01';
+----------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+----------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+----------------+----------+----------------+---------+
| doudou01 | MyISAM | 10 | Fixed | 0 | 0 | 0 | 2533274790395903 | 1024 | 0 | 1 | 2016-03-18 11:10:59 | 2016-03-18 11:10:59 | NULL | gbk_chinese_ci | NULL | | |
+----------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+----------------+----------+----------------+---------+
1 row in set (0.00 sec)
CREATE TABLE `doudou02` (
`country_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`country` varchar(50) NOT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`country_id`)
)
ENGINE=InnoDB DEFAULT CHARSET=gbk;
2.change table engine
2.1 change from myisam table to innodb table
## add innodb_buffer_pool have up to 3 times
## Why add innodb_buffer_poor ?
## Solution : The reason for the increase in buffer pool memory is that InnoDB often
has up to 3 times larger storage
## requirements than MyISAM as InnoDB stores both data and indexes in memory, but MYISAM only stores indexes.
alter table doudou01 engine=innodb;
## check table status
mysql>
show table status like 'doudou01';
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+----------------+----------+----------------+---------+
| doudou01 | InnoDB | 10 | Compact | 0 | 0 | 16384 | 0 | 0 | 0 | 1 | 2016-03-18 11:19:44 | NULL | NULL | gbk_chinese_ci | NULL | | |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+----------------+----------+----------------+---------+
1 row in set (0.01 sec)
2.2 change from innodb table to myisam table
alter table doudou02 engine=myisam;
3.Why does converting tables from MyISAM to Innodb cause performance problems? (文件 ID 1023535.1)
Discussion
All storage engines have different performance properties and even though MySQL provides the same basic functionality for all storage engines, changing storage engines should not be taken lightly from a performance standpoint. The list below includes the most common causes of performance regressions while converting to Innodb and includes some tips related to them:
Innodb tables typically have larger memory and disk footprint, so disk performance requirements and size of memory grows to maintain the same level of performance.
Innodb tables are much more sensible to server settings. Therefore, make sure innodb_buffer_pool and innodb_log_file_size are adjusted to reflect your load and hardware configuraton.
Innodb tables are clustered by the primary key. If you're performing operations with random primary key values, they may be slower than MyISAM tables. This especially applies to inserts.
LOAD DATA and Index Build operations are not optimized for Innodb and always performed row by row, instead of by sorting the data.
Innodb uses the primary key as row pointers for Secondary indexes, so Index long primary key may decrease performance significantly, especially for key accesses.
Innodb uses synchronous disk I/O requiring the disk to report that data is actually written to the plate before it can consider operation completed. This increases data security, but reduces performance, especially on lower end disk sub-systems.
Innodb is a transactional and multi-versioning storage engine. This means it has to deal with the appropriate overhead such as maintaining a transaction log and undo tablespace with previous row versions.
4.Comparing Innodb And MyISAM Storage Engines (文件 ID 1588042.1)
The general recommendations would be:
InnoDB: Any transactions, finer tuning and larger throughput
MyISAM: transactions are not required, mainly inserts and/or reads, GIS data and indexing
########################################################################################
版權所有,文章允許轉載,但必須以連結方式註明源地址,否則追究法律責任!【QQ交流群:53993419】
QQ:14040928 E-mail:dbadoudou@163.com
本文連結: http://blog.itpub.net/26442936/viewspace-2059382/
********* 6年DBA工作經驗,尋求新工作機會 *********
########################################################################################
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-2059382/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL:ERROR 1286 (42000): Unknown storage engine 'MyISAM'MySqlError
- Azure Storage 系列(四)在.Net 上使用Table Storage
- Failed to read auto-increment value from storage engineAIREM
- Azure Storage 系列(五)通過Azure.Cosmos.Table 類庫在.Net 上使用 Table Storage
- Azure Table Storage(一) : 簡單介紹
- mysql change buffer小結MySql
- 解決ERROR 1030 (HY000): Got error 168 from storage engine apparmorErrorGoAPP
- MySQL的show engine innodb statusMySql
- MySQL:Analyze table導致'waiting for table flush'MySqlAI
- MySQL table into a golang strucMySqlGolang
- mysql alter modify 和 change的區別MySql
- After mysql installation, we need to change the password of root as belowMySql
- 技術分享 | MySQL:change buffer 何時生效MySql
- MySQL學習之change buffer 和 redo logMySql
- 【mysql】table中新增列MySql
- mysql的ALTER TABLE命令MySql
- MySQL rename table方法大全MySql
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- mysql的唯一索引不會利用change bufferMySql索引
- 【Azure 儲存服務】Python模組(azure.cosmosdb.table)直接對錶儲存(Storage Account Table)做操作示例Python
- mysql之 OPTIMIZE TABLE整理碎片MySql
- MySQL5.7 Waiting FOR TABLE FLUSHMySqlAI
- MySQL:Table_open_cache_hits/Table_open_cache_misses/Table_open_cache_overflowsMySql
- MySQL修改大表工具pt-online-schema-change原理MySql
- MySQL:pt-online-schema-change原理及注意點(未完)MySql
- sqlserver Change Data Capture&Change TrackingSQLServerAPT
- 【MySQL】七、再說MySQL中的 table_idMySql
- MySQL5.6 create table原理分析MySql
- MySQL 關於Table cache設定MySql
- Mysql用optimize table 最佳化MySql
- MySQL 資料庫的提速器-寫快取(Change Buffer)MySql資料庫快取
- 一個 MySQL 線上 DDL 工具 — pt-online-schema-changeMySql
- MySQL AttributeError: ‘Engine’物件沒有’execute’屬性的錯誤MySqlError物件
- MySQL:5.6 大事務show engine innodb status故障一例MySql
- MySQL-ALTER TABLE命令學習[20180503]MySql
- MySQL的create table as 與 like區別MySql
- MySQL新增索引偶遇waiting for table metadata lockMySql索引AI
- MySQL DDL Waiting for table metadata lock 解決MySqlAI
- 關於 mysql 中的 select * from table_a,table_b 的問題MySql