数据库类型空间效率探索(四)-tinyint与enum与set
mysql> select count(*) from userinfo;
+----------+
| count(*) |
+----------+
| 115597 |
+----------+
1 row in set (0.00 sec)
mysql> select concat(truncate(sum(data_length)/1024/1024,3),'MB') as data_size,
-> concat(truncate(sum(max_data_length)/1024/1024,3),'MB') as max_data_leng
th,
-> concat(truncate(sum(data_free)/1024/1024,3),'MB') as data_free,
-> concat(truncate(sum(index_length)/1024/1024,3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.477MB | 268435455.999MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
以下测试tinyint
mysql> ALTER TABLE `userinfo`
-> ADD COLUMN `type` tinyint NOT NULL DEFAULT 0 COMMENT '反应类型' AFTER `i
ntegral`;
Query OK, 115597 rows affected (0.54 sec)
Records: 115597 Duplicates: 0 Warnings: 0
mysql> select concat(truncate(sum(data_length)/1024/1024,3),'MB') as data_size,
-> concat(truncate(sum(max_data_length)/1024/1024,3),'MB') as max_data_leng
th,
-> concat(truncate(sum(data_free)/1024/1024,3),'MB') as data_free,
-> concat(truncate(sum(index_length)/1024/1024,3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.477MB | 268435455.999MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
mysql> insert into userinfo(app,imei,type) values('','0',43);
Query OK, 1 row affected (0.00 sec)
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo'
-> ;
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.478MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.00 sec)
mysql> update userinfo set type=30;
Query OK, 115598 rows affected (2.70 sec)
Rows matched: 115598 Changed: 115598 Warnings: 0
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 22.038MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.00 sec)
以下测试enum
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.478MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
mysql> ALTER TABLE `userinfo`
-> ADD COLUMN `type` enum('未知','化合','分解','置换','复分解','取代','加成'
,'消去','加聚','酯化','水解','聚合','缩聚','吸热','放热','氧化','还原') AFTER `i
ntegral`;
Query OK, 115597 rows affected (0.63 sec)
Records: 115597 Duplicates: 0 Warnings: 0
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.694MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.00 sec)
mysql> update userinfo set type='复分解';
Query OK, 115597 rows affected (2.54 sec)
Rows matched: 115597 Changed: 115597 Warnings: 0
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.694MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.00 sec)
以下测试set
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo'
-> ;
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.478MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.00 sec)
mysql> ALTER TABLE `userinfo`
-> ADD COLUMN `type` set('未知','化合','分解','置换','复分解','取代','加成',
'消去','加聚','酯化','水解','聚合','缩聚','吸热','放热','氧化','还原') AFTER `in
tegral`;
Query OK, 115597 rows affected (0.61 sec)
Records: 115597 Duplicates: 0 Warnings: 0
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 21.590MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.01 sec)
mysql> update userinfo set type='加成';
Query OK, 115597 rows affected (3.63 sec)
Rows matched: 115597 Changed: 115597 Warnings: 0
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 23.235MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.00 sec)
mysql> update userinfo set type='加成,取代,消去,放热';
Query OK, 115597 rows affected (4.37 sec)
Rows matched: 115597 Changed: 115597 Warnings: 0
mysql> select concat(round(sum(data_length/1024/1024),3),'MB') as data_size,
-> concat(round(sum(max_data_length/1024/1024),3),'MB') as max_data_length,
-> concat(round(sum(data_free/1024/1024),3),'MB') as data_free,
-> concat(round(sum(index_length/1024/1024),3),'MB') as index_length
-> from information_schema.tables where table_name='userinfo';
+-----------+-----------------+-----------+--------------+
| data_size | max_data_length | data_free | index_length |
+-----------+-----------------+-----------+--------------+
| 23.235MB | 268435456.000MB | 0.000MB | 1.319MB |
+-----------+-----------------+-----------+--------------+
1 row in set (0.01 sec)
数据库类型空间效率探索(四)-tinyint与enum与set的更多相关文章
- 数据库类型空间效率探索(五)- decimal/float/double/varchar
以下测试为userinfo增加一列,列类型分别为decimal.float.double.varchar.由于innodb不支持optimize,所以每次测试,都会删除表test.userinfo,重 ...
- 数据库类型空间效率探索(三)-char
测试环境 表信息 表数据量22.23万,占用空间44.494M 用到的sql语句 增加列:alter table t_type add column new_column char(1) defaul ...
- Oracle数据库类型
Oracle数据库类型 字符类型char[(length)] 定长字符 最长2000字节varchar2[(length)] 可变长度的字符数据类型,最长4000字节NCHAR[(length)] 固 ...
- MySql数据库优化必须注意的四个细节(方法)
MySQL 数据库性能的优化是 MySQL 数据库发展的必经之路, MySQL 数据库性能的优化也是 MySQL 数据库前进的见证,下文中将从从4个方面给出了 MySQL 数据库性能优化的方法. 1. ...
- 数据库表空间收缩之pg_squeeze,pg_repack
数据库表空间收缩之pg_squeeze,pg_repack 目录 数据库表空间收缩之pg_squeeze,pg_repack pg_squeeze1.2 原理 优点 安装 使用 pgstattuple ...
- oracle数据库表空间追加数据库文件方法
oracle数据库表空间追加数据库文件方法 针对非大文件方式表空间,允许追加文件进行表空间的扩展,单个文件最大大小是32G 第一种方式:表空间增加数据文件 www.2cto.com 1 ...
- Java与数据库类型对照表
数据库类型 Java类型 INTEGER int or java.lang.Integer BIGINT long or java.lang.Long SMALLINT short o ...
- Spring MVC动态切换数据源(多数据库类型)
最近由于项目需求,需要将Sql Server 和 Mysql 两种数据库整合到一个项目,项目的用到的框架是SSM. 因此尝试了利用AOP切面来切每次执行的Servcie方法,根据Service所在的包 ...
- [C#]实现任何数据库类型的DbHelper帮助类
本文章为原创内容,如需转载,请注明作者及出处,谢谢! 一.在System.Data.Common命名空间下,存在这样的一个类: // // 摘要: // 表示一组方法,这些方法用于创建提供程序对数据源 ...
随机推荐
- 高并发和大流量解决方案--CND加速
CDN全称 Content Delivery Network,即内容分发网络.其基本思路是尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,使内容传输的更快.更稳定.通过在网络各处放置节点 ...
- elasticsearch-java
elastissearch的JAVA客户端 官网 java api文档 https://www.elastic.co/guide/en/elasticsearch/client/java-api/ ...
- BBS-基于用户认证组建和Ajax实现登陆验证
功能1: 基于用户认证组件和Ajax实现登录验证(图片验证码) 总结: 1 一次请求伴随多次请求 2 PIL 3 session存储 4 验证码刷新 步骤: 1.配置静态文件夹 settings.py ...
- 16_虚拟dom和dom diff算法
虚拟dom的作用:是为了减少操作真实的dom 初始化显示界面的过程: 1.创建虚拟dom树——>真实dom树——>绘制页面显示 更新界面的过程: 2.绘制页面显示——>setStat ...
- html _ 提取html片段内的纯文本
var html = “html字符串”;var textstr =html.replace(/<[^>]*>|/g,"");//纯文本
- Linux 循环创建多个线程
这里说一下相关的基础知识: 线程概念 什么是线程 LWP:light weight process 轻量级的进程,本质仍是进程(在Linux环境下) 进程:独立地址空间,拥有PCB 线 ...
- U3D 编辑器中sceneview下相机操作相关
前几天在项目中想要实现一个编辑器模式下的3D空间画线功能,几经周折,还是作废. 原因有:相机空间到世界空间转换问题对于Z值不清楚,U3D自定义坐标轴控制问题,射线与平面求交点不对, 一个关键问题是:编 ...
- Object-c 调用unity的 UIViewController和UnitySendMessage
.mm文件中实现 #import <UIKit/UIKit.h> extern UIViewController *UnityGetGLViewController(); extern & ...
- Spring格式化注解
Spring Framework 3.0发布了.这里我们介绍其中的一个:用于格式化的注解.简介 Spring 3 提供了两个可以用于格式化数字.日期和时间的注解@NumberFormat和@DateT ...
- JAVA仿百度分页
最近在做一个仿百度网盘的网页小应用,找到了一个优雅简洁的分页插件,和百度搜索的分页很相似,对他进行了二次封装,拿出来跟大家分享下 插件源码 /** * This jQuery plugin displ ...