[ 丹臣]INNODB與ORACLE單行儲存長度對比
眾所周知,mysql innodb儲存引擎與oracle非常相似,支援事務,row-locking,經過實際測試,innodb與oracle一個比較大的差異點為,在此測試用例下,相同資料,innodb單行儲存長度大概是oracle單行儲存長度的1.8倍。
測試的表,常見的各種型別都有,number,varchar2,date
–首先在oracle中做測試 , 在oracle資料庫中此表單行長度平均為458位元組
09:49:45 danchen@ test_oracle>select blocks from dba_extents where segment_name='test_dc' and rownum<2;
BLOCKS
----------
1280
1 row selected.
09:52:55 danchen@ test_oracle>select /*+ rowid(u)*/ count(*) from test_dc u where rowid>=CHARTOROWID('AAADQdAA6AAADcJAAA') and rowid<=CHARTOROWID('AAADQdAA6AAADwICcQ');
COUNT(*)
----------
22852
09:54:55 danchen@ test_oracle>select 1280*8*1024/22852 bytes from dual;
BYTES
----------
458.855242
BLOCKS
----------
1280
1 row selected.
09:52:55 danchen@ test_oracle>select /*+ rowid(u)*/ count(*) from test_dc u where rowid>=CHARTOROWID('AAADQdAA6AAADcJAAA') and rowid<=CHARTOROWID('AAADQdAA6AAADwICcQ');
COUNT(*)
----------
22852
09:54:55 danchen@ test_oracle>select 1280*8*1024/22852 bytes from dual;
BYTES
----------
458.855242
–在mysql作對比測試
root@test_mysql 09:47:47>select count(*) from test_dc_181;
+----------+
| count(*) |
+----------+
| 128928 |
+----------+
1 row in set (0.08 sec)
root@test_mysql 09:45:57>show table status like 'test_dc_181'\G;
*************************** 1. row ***************************
Name: test_dc_181
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 85668 --統計資訊不準確
Avg_row_length: 1122
Data_length: 96141312
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: NULL
Create_time: 2009-05-27 11:23:55
Update_time: NULL
Check_time: NULL
Collation: gbk_chinese_ci
Checksum: NULL
Create_options:
Comment: InnoDB free: 292984832 kB
1 row in set (0.00 sec)
ERROR:
No query specified
+----------+
| count(*) |
+----------+
| 128928 |
+----------+
1 row in set (0.08 sec)
root@test_mysql 09:45:57>show table status like 'test_dc_181'\G;
*************************** 1. row ***************************
Name: test_dc_181
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 85668 --統計資訊不準確
Avg_row_length: 1122
Data_length: 96141312
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: NULL
Create_time: 2009-05-27 11:23:55
Update_time: NULL
Check_time: NULL
Collation: gbk_chinese_ci
Checksum: NULL
Create_options:
Comment: InnoDB free: 292984832 kB
1 row in set (0.00 sec)
ERROR:
No query specified
–重新分析一下,發現執行分析操作時間非常快,資料也比較準確,估計mysql的分析的演算法原理為基於抽樣的統計,比如說一個page裡有多少記錄,總的page數是多少,兩者相乘即可得到行數。
root@test_mysql 09:46:01>analyze table test_dc_181;
+---------------------+---------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+---------------------+---------+----------+----------+
| test_mysql.test_dc_181 | analyze | status | OK |
+---------------------+---------+----------+----------+
1 row in set (0.00 sec)
root@test_mysql 09:46:46>show table status like 'test_dc_181'\G;
*************************** 1. row ***************************
Name: test_dc_181
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 115074
Avg_row_length: 835
Data_length: 96141312
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: NULL
Create_time: 2009-05-27 11:23:55
Update_time: NULL
Check_time: NULL
Collation: gbk_chinese_ci
Checksum: NULL
Create_options:
Comment: InnoDB free: 292984832 kB
1 row in set (0.00 sec)
ERROR:
No query specified
+---------------------+---------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+---------------------+---------+----------+----------+
| test_mysql.test_dc_181 | analyze | status | OK |
+---------------------+---------+----------+----------+
1 row in set (0.00 sec)
root@test_mysql 09:46:46>show table status like 'test_dc_181'\G;
*************************** 1. row ***************************
Name: test_dc_181
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 115074
Avg_row_length: 835
Data_length: 96141312
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: NULL
Create_time: 2009-05-27 11:23:55
Update_time: NULL
Check_time: NULL
Collation: gbk_chinese_ci
Checksum: NULL
Create_options:
Comment: InnoDB free: 292984832 kB
1 row in set (0.00 sec)
ERROR:
No query specified
–在mysql innodb的表中平均單行長度為835位元組
root@test_mysql 09:46:50>select 96141312/115074;
+-----------------+
| 96141312/115074 |
+-----------------+
| 835.4738 |
+-----------------+
1 row in set (0.00 sec)
+-----------------+
| 96141312/115074 |
+-----------------+
| 835.4738 |
+-----------------+
1 row in set (0.00 sec)
–在此測試用例下,同一行記錄,在oracle與mysql儲存空間對比為1.8:1,在其它大多數情況下,oracle的資料遷移到mysql資料庫,所用的空間都要大許多,具體大多少,各位需要經過測試,以使容量估計更加準確。
root@test_mysql 09:48:14>select 835.4738/458.855242 ;
+---------------------+
| 835.4738/458.855242 |
+---------------------+
| 1.82077859 |
+---------------------+
1 row in set (0.00 sec)
+---------------------+
| 835.4738/458.855242 |
+---------------------+
| 1.82077859 |
+---------------------+
1 row in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/1384/viewspace-611328/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [ 丹臣]利用innodb_table_monitor來trace innodb內部資訊
- [丹臣]ORACLE中Like與Instr效能大比拼Oracle
- 檔案系統儲存與oracle資料庫儲存對比Oracle資料庫
- MySQL三種InnoDB、MyISAM和MEMORY儲存引擎對比MySql儲存引擎
- 【丹臣】優化SQL的另類思考優化SQL
- MySQL和Oracle對比之儲存過程MySqlOracle儲存過程
- KV儲存的對比
- Innodb儲存引擎儲存引擎
- MyISAM 儲存引擎,Innodb 儲存引擎儲存引擎
- InnoDB儲存引擎——後臺執行緒儲存引擎執行緒
- MySQL儲存引擎--MyISAM與InnoDB區別MySql儲存引擎
- Oracle儲存單位Oracle
- InnoDB儲存引擎——表儲存引擎
- MySQL InnoDB儲存引擎MySql儲存引擎
- MySQL的鍵值儲存以及與MongoDB的對比MySqlMongoDB
- ORACLE PL/SQL 物件、表資料對比功能儲存過程簡單實現OracleSQL物件儲存過程
- MyISAM與innoDB儲存引擎有何差別儲存引擎
- MySQL儲存引擎MyISAM與InnoDB的優劣MySql儲存引擎
- 儲存技術對比:NVMe與SATA孰強孰弱?
- InnoDB儲存引擎簡介儲存引擎
- InnoDB儲存引擎檔案儲存引擎
- MySQL Innodb 儲存結構 & 儲存Null值 解析MySqlNull
- 總結MySQL儲存引擎MyISAM與InnoDB區別MySql儲存引擎
- MySQL 如何儲存長度很長的資料欄位MySql
- 面向不同需求的物件儲存系統對比:Ceph與Swift物件Swift
- 資料儲存加密的主流方案對比與難點解析加密
- Mysql技術內幕InnoDB儲存引擎讀書筆記--《二》InnoDB儲存引擎MySql儲存引擎筆記
- MySQL InnoDB 儲存引擎探祕MySql儲存引擎
- InnoDB記錄儲存結構
- InnoDB儲存引擎——兩次寫儲存引擎
- InnoDB儲存引擎——記憶體儲存引擎記憶體
- InnoDB儲存引擎——Checkpoint技術儲存引擎
- InnoDB儲存引擎——插入緩衝儲存引擎
- InnoDB儲存引擎——非同步IO儲存引擎非同步
- MySQL兩種儲存引擎: MyISAM和InnoDB 簡單總結MySql儲存引擎
- MySQL的varchar儲存原理:InnoDB記錄儲存結構MySql
- VMware 與 SmartX 分散式儲存快取機制淺析與效能對比分散式快取
- 深入瞭解瀏覽器儲存:對比Cookie、LocalStorage、sessionStorage與IndexedDB瀏覽器CookieSessionIndex