始创于2000年 股票代码:831685
咨询热线:0371-60135900 注册有礼 登录
  • 挂牌上市企业
  • 60秒人工响应
  • 99.99%连通率
  • 7*24h人工
  • 故障100倍补偿
您的位置: 网站首页 > 帮助中心>文章内容

InnoDB与Oracle单行存储长度对比

发布时间:  2012/8/10 17:51:03

众所周知,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

--在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


--重新分析一下,发现执行分析操作时间非常快,数据也比较准确,估计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

--在mysql innodb的表中平均单行长度为835字节

root@test_mysql 09:46:50>select 96141312/115074;
+-----------------+
| 96141312/115074 |
+-----------------+
|        835.4738 |
+-----------------+
1 row in set (0.00 sec)


--同一行记录,在Oracle与mysql存储空间对比为1.8:1,所以在做容量估计的时候要注意。
root@test_mysql 09:48:14>select 835.4738/458.855242 ;
+---------------------+
| 835.4738/458.855242 |
+---------------------+
|          1.82077859 |
+---------------------+
1 row in set (0.00 sec)


本文出自:亿恩科技【www.enkj.com】

服务器租用/服务器托管中国五强!虚拟主机域名注册顶级提供商!15年品质保障!--亿恩科技[ENKJ.COM]

  • 您可能在找
  • 亿恩北京公司:
  • 经营性ICP/ISP证:京B2-20150015
  • 亿恩郑州公司:
  • 经营性ICP/ISP/IDC证:豫B1.B2-20060070
  • 亿恩南昌公司:
  • 经营性ICP/ISP证:赣B2-20080012
  • 服务器/云主机 24小时售后服务电话:0371-60135900
  • 虚拟主机/智能建站 24小时售后服务电话:0371-60135900
  • 专注服务器托管17年
    扫扫关注-微信公众号
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 亿恩科技 版权所有  地址:郑州市高新区翠竹街1号总部企业基地亿恩大厦  法律顾问:河南亚太人律师事务所郝建锋、杜慧月律师   京公网安备41019702002023号
      0
     
     
     
     

    0371-60135900
    7*24小时客服服务热线