准备数据 sysbench --test=oltp --oltp-nontrx-mode=update_key --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-socket=/tmp/mysql3392.sock --mysql-user=dba --mysql-host=localhost --mysql-password=localdba --db-driver=mysql --mysq
准备数据
sysbench --test=oltp --oltp-nontrx-mode=update_key --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-socket=/tmp/mysql3392.sock --mysql-user=dba --mysql-host=localhost --mysql-password=localdba --db-driver=mysql --mysql-db=test prepare
mysql> desc sbtest;
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| k | int(10) unsigned | NO | MUL | 0 | |
| c | char(120) | NO | | | |
| pad | char(60) | NO | | | |
+-------+------------------+------+-----+---------+----------------+
mysql> select count(c) from sbtest;
+----------+
| count(c) |
+----------+
| 1000000 |
+----------+
char的情况下:::
mysql> desc select * from sbtest order by pad;
+----+-------------+--------+------+---------------+------+---------+------+---------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+---------+----------------+
| 1 | SIMPLE | sbtest | ALL | NULL | NULL | NULL | NULL | 1000126 | Using filesort |
+----+-------------+--------+------+---------------+------+---------+------+---------+----------------+
mysql> set profiling = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> select count(*) from sbtest order by pad;
+----------+
| count(*) |
+----------+
| 1000000 |
+----------+
1 row in set (0.53 sec)
mysql> show profiles;
+----------+------------+------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------------------------------+
| 1 | 0.53102850 | select count(*) from sbtest order by pad |
+----------+------------+------------------------------------------+
1 row in set (0.02 sec)
mysql> show profile cpu,block io for query 1;
+----------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+----------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000127 | 0.000000 | 0.000000 | 0 | 0 |
| checking permissions | 0.000017 | 0.000000 | 0.000000 | 0 | 0 |
| Opening tables | 0.000042 | 0.000000 | 0.000000 | 0 | 0 |
| System lock | 0.000022 | 0.000000 | 0.000000 | 0 | 0 |
| init | 0.000038 | 0.000000 | 0.000000 | 0 | 0 |
| optimizing | 0.000011 | 0.000000 | 0.000000 | 0 | 0 |
| statistics | 0.000022 | 0.000000 | 0.000000 | 0 | 0 |
| preparing | 0.000017 | 0.000000 | 0.000000 | 0 | 0 |
| executing | 0.000014 | 0.000000 | 0.000000 | 0 | 0 |
| Sending data | 0.530471 | 0.502923 | 0.018997 | 32 | 0 |
| end | 0.000034 | 0.000000 | 0.000000 | 0 | 0 |
| query end | 0.000010 | 0.000000 | 0.000000 | 0 | 0 |
| closing tables | 0.000025 | 0.000000 | 0.000000 | 0 | 0 |
| freeing items | 0.000037 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000004 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000128 | 0.000000 | 0.000000 | 0 | 8 |
| cleaning up | 0.000012 | 0.000000 | 0.000000 | 0 | 0 |
+----------------------+----------+----------+------------+--------------+---------------+
/////char change to varchar
mysql> alter table sbtest change pad pad varchar(60);
Query OK, 1000000 rows affected (10.72 sec)
Records: 1000000 Duplicates: 0 Warnings: 0
mysql> select pad from sbtest limit 30;
+----------------------------------------------------+
| pad |
+----------------------------------------------------+
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
| qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt |
mysql> desc sbtest;
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| k | int(10) unsigned | NO | MUL | 0 | |
| c | char(120) | NO | | | |
| pad | varchar(60) | YES | | NULL | |
+-------+------------------+------+-----+---------+----------------+
================无索引的情况下:=====================
varchar(60)的情况下:
mysql> desc select * from sbtest order by pad;
+----+-------------+--------+------+---------------+------+---------+------+---------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+---------+----------------+
| 1 | SIMPLE | sbtest | ALL | NULL | NULL | NULL | NULL | 1000117 | Using filesort |
+----+-------------+--------+------+---------------+------+---------+------+---------+----------------+
mysql> select count(*) from sbtest order by pad;
+----------+
| count(*) |
+----------+
| 1000000 |
+----------+
1 row in set (0.51 sec)
mysql> show profile cpu,block io for query 11;
+----------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+----------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000081 | 0.000000 | 0.000000 | 0 | 0 |
| checking permissions | 0.000014 | 0.000000 | 0.000000 | 0 | 0 |
| Opening tables | 0.000033 | 0.000000 | 0.000000 | 0 | 0 |
| System lock | 0.000025 | 0.000000 | 0.000000 | 0 | 0 |
| init | 0.000028 | 0.000000 | 0.000000 | 0 | 0 |
| optimizing | 0.000009 | 0.000000 | 0.000000 | 0 | 0 |
| statistics | 0.000019 | 0.000000 | 0.000000 | 0 | 0 |
| preparing | 0.000013 | 0.000000 | 0.000000 | 0 | 0 |
| executing | 0.000011 | 0.000000 | 0.000000 | 0 | 0 |
| Sending data | 0.506327 | 0.489925 | 0.018997 | 0 | 0 |
| end | 0.000026 | 0.001000 | 0.000000 | 0 | 0 |
| query end | 0.000010 | 0.000000 | 0.000000 | 0 | 0 |
| closing tables | 0.000022 | 0.000000 | 0.000000 | 0 | 0 |
| freeing items | 0.000034 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000003 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000114 | 0.000000 | 0.000000 | 0 | 8 |
| cleaning up | 0.000009 | 0.000000 | 0.000000 | 0 | 0 |
+----------------------+----------+----------+------------+--------------+---------------+
varchar(120)的情况下:
mysql> alter table sbtest change pad pad varchar(120);
Query OK, 1000000 rows affected (11.77 sec)
Records: 1000000 Duplicates: 0 Warnings: 0
mysql> desc sbtest;
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| k | int(10) unsigned | NO | MUL | 0 | |
| c | char(120) | NO | | | |
| pad | varchar(120) | YES | | NULL | |
+-------+------------------+------+-----+---------+----------------+
mysql> desc select * from sbtest;
+----+-------------+--------+------+---------------+------+---------+------+---------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+---------+-------+
| 1 | SIMPLE | sbtest | ALL | NULL | NULL | NULL | NULL | 1000117 | |
+----+-------------+--------+------+---------------+------+---------+------+---------+-------+
1 row in set (0.00 sec)
mysql> desc select count(*) from sbtest;
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | sbtest | index | NULL | k | 4 | NULL | 1000117 | Using index |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
1 row in set (0.00 sec)
mysql> select count(*) from sbtest order by pad;
+----------+
| count(*) |
+----------+
| 1000000 |
+----------+
1 row in set (0.51 sec)
mysql> show profile cpu,block io for query 17;
+----------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+----------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000073 | 0.000000 | 0.000000 | 0 | 0 |
| checking permissions | 0.000013 | 0.000000 | 0.000000 | 0 | 0 |
| Opening tables | 0.000031 | 0.000000 | 0.000000 | 0 | 0 |
| System lock | 0.000024 | 0.000000 | 0.000000 | 0 | 0 |
| init | 0.000026 | 0.000000 | 0.000000 | 0 | 0 |
| optimizing | 0.000008 | 0.000000 | 0.000000 | 0 | 0 |
| statistics | 0.000019 | 0.000000 | 0.000000 | 0 | 0 |
| preparing | 0.000013 | 0.000000 | 0.000000 | 0 | 0 |
| executing | 0.000011 | 0.000000 | 0.000000 | 0 | 0 |
| Sending data | 0.510981 | 0.491925 | 0.018997 | 0 | 0 |
| end | 0.000025 | 0.000000 | 0.000000 | 0 | 0 |
| query end | 0.000013 | 0.000000 | 0.000000 | 0 | 0 |
| closing tables | 0.000026 | 0.000000 | 0.000000 | 0 | 0 |
| freeing items | 0.000039 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000004 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000110 | 0.000000 | 0.000000 | 0 | 8 |
| cleaning up | 0.000007 | 0.000000 | 0.000000 | 0 | 0 |
+----------------------+----------+----------+------------+--------------+---------------+
================有索引的情况下:=====================
alter table sbtest change pad pad varchar(60);
mysql> alter table sbtest add key(pad);
Query OK, 0 rows affected (7.60 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show index from sbtest;
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| sbtest | 0 | PRIMARY | 1 | id | A | 1000117 | NULL | NULL | | BTREE | | |
| sbtest | 1 | k | 1 | k | A | 6 | NULL | NULL | | BTREE | | |
| sbtest | 1 | pad | 1 | pad | A | 200 | NULL | NULL | YES | BTREE | | |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
varchar(60)
mysql> desc select count(*) from sbtest order by pad;
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | sbtest | index | NULL | pad | 183 | NULL | 1000117 | Using index |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
mysql> select count(*) from sbtest order by pad;
+----------+
| count(*) |
+----------+
| 1000000 |
+----------+
1 row in set (0.44 sec)
mysql> show profile cpu,block io for query 1
-> ;
+----------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+----------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000115 | 0.000000 | 0.000000 | 0 | 0 |
| checking permissions | 0.000017 | 0.000000 | 0.000000 | 0 | 0 |
| Opening tables | 0.000043 | 0.000000 | 0.000000 | 0 | 0 |
| System lock | 0.000023 | 0.000000 | 0.000000 | 0 | 0 |
| init | 0.000038 | 0.000000 | 0.000000 | 0 | 0 |
| optimizing | 0.000010 | 0.000000 | 0.000000 | 0 | 0 |
| statistics | 0.000024 | 0.000000 | 0.000000 | 0 | 0 |
| preparing | 0.000018 | 0.000000 | 0.000000 | 0 | 0 |
| executing | 0.000015 | 0.000000 | 0.000000 | 0 | 0 |
| Sending data | 0.445040 | 0.428935 | 0.015998 | 0 | 0 |
| end | 0.000023 | 0.000000 | 0.000000 | 0 | 0 |
| query end | 0.000013 | 0.000000 | 0.000000 | 0 | 0 |
| closing tables | 0.000028 | 0.000000 | 0.000000 | 0 | 0 |
| freeing items | 0.000041 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000003 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000133 | 0.000000 | 0.001000 | 0 | 8 |
| cleaning up | 0.000008 | 0.000000 | 0.000000 | 0 | 0 |
+----------------------+----------+----------+------------+--------------+---------------+
varchar(120)的:
mysql> alter table sbtest change pad pad varchar(120);
Query OK, 1000000 rows affected (14.56 sec)
Records: 1000000 Duplicates: 0 Warnings: 0
mysql> show index from sbtest;
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| sbtest | 0 | PRIMARY | 1 | id | A | 1000117 | NULL | NULL | | BTREE | | |
| sbtest | 1 | k | 1 | k | A | 6 | NULL | NULL | | BTREE | | |
| sbtest | 1 | pad | 1 | pad | A | 24 | NULL | NULL | YES | BTREE | | |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
这里开始有区别了.Cardinality 从200降到24
varchar(120) Cardinality =200
varchar(60) Cardinality =40 ... 字段是全部60char长度的
mysql> desc select count(*) from sbtest order by pad;
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | sbtest | index | NULL | pad | 363 | NULL | 1000117 | Using index |
+----+-------------+--------+-------+---------------+------+---------+------+---------+-------------+
mysql> select count(*) from sbtest order by pad;
+----------+
| count(*) |
+----------+
| 1000000 |
+----------+
1 row in set (0.45 sec)
mysql> show profile cpu,block io for query 8;
+----------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+----------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000120 | 0.000000 | 0.000000 | 0 | 0 |
| checking permissions | 0.000017 | 0.000000 | 0.000000 | 0 | 0 |
| Opening tables | 0.000046 | 0.000000 | 0.000000 | 0 | 0 |
| System lock | 0.000028 | 0.000000 | 0.000000 | 0 | 0 |
| init | 0.000038 | 0.000000 | 0.000000 | 0 | 0 |
| optimizing | 0.000011 | 0.000000 | 0.000000 | 0 | 0 |
| statistics | 0.000023 | 0.000000 | 0.000000 | 0 | 0 |
| preparing | 0.000018 | 0.000000 | 0.000000 | 0 | 0 |
| executing | 0.000013 | 0.000000 | 0.000000 | 0 | 0 |
| Sending data | 0.452434 | 0.437933 | 0.014998 | 0 | 0 |
| end | 0.000025 | 0.000000 | 0.000000 | 0 | 0 |
| query end | 0.000010 | 0.000000 | 0.000000 | 0 | 0 |
| closing tables | 0.000023 | 0.000000 | 0.000000 | 0 | 0 |
| freeing items | 0.000033 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000003 | 0.000000 | 0.000000 | 0 | 0 |
| logging slow query | 0.000098 | 0.000000 | 0.000000 | 0 | 8 |
| cleaning up | 0.000007 | 0.000000 | 0.000000 | 0 | 0 |
+----------------------+----------+----------+------------+--------------+---------------+
这里也有区别了.有索引的情况下,
是0.44 pk 0.45s
=====================================================================================================
加到varchar(600)试下
mysql> alter table sbtest change pad pad varchar(600);
Query OK, 1000000 rows affected, 2 warnings (14.60 sec)
Records: 1000000 Duplicates: 0 Warnings: 2
mysql> desc select count(*) from sbtest order by pad;
+----+-------------+--------+------+---------------+------+---------+------+---------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+---------+-------+
| 1 | SIMPLE | sbtest | ALL | NULL | NULL | NULL | NULL | 1000117 | |
+----+-------------+--------+------+---------------+------+---------+------+---------+-------+
1 row in set (0.01 sec)
mysql> select count(*) from sbtest order by pad;
+----------+
| count(*) |
+----------+
| 1000000 |
+----------+
1 row in set (0.50 sec)
600是0.5s....

1t内存等于1024GB。1t内存是指内存的存储容量为“1TB”,而1TB等于1024GB。但这只是计算机原理中理论上的数值,一般在系统显示可用存储空间中会偏少;因为硬盘制造商对硬盘的定义与计算机对硬盘容量的算法不同,导致硬盘标识容量和操作系统中显示的实际容量存在误差。

gear1和gear2内存模式指的是CPU的内存控制器与内存频率的比例关系;gear1表示内存控制器频率和内存工作频率之比是“1:1”,而gear2表示内存控制器频率和内存工作频率之比是“1:2”,可减轻内存控制器压力,让内存更容易得到更高的频率。

电脑C盘一般留50-80G,由于系统在日后使用当中会产生垃圾文件和缓存文件等,因此建议至少预留50GB-80GB的空间给C盘,如果不习惯在安装软件时选择路径,日常也不经常清理电脑,那么至少需要100GB。

板载内存是指主板上本身集成的内存,是直接焊接在了电脑的主板上无法更换的。板载有“集成”的意思,是指整合于主板芯片中的功能或硬件,主要有板载显卡、声卡、网卡、RAID等。一般板载硬件功能都较简单,不能完全取代独立硬件;但是购买可以控制购买成本。

1tb理论上是等于1024g;其中T是TB的缩写,G是GB的缩写,但是一般内存不会有1TB的,TB级别的是硬盘;TB表示太字节,是一种信息计量单位,现今通常在标示硬盘总容量、或具有大容量的储存介质之储存容量时使用。

内存或磁盘不足,word无法显示请求字体的解决办法:1、打开Word,点击【剪切板】,然后点击【全部清空】;2、在【高级系统设置】中取消勾选“自动管理所有驱动器的分页文件大小”的选项,然后选中需要设置的磁盘盘符,输入合适的大小即可。

硬盘是外存。外存全称“外存储器”,是指除计算机内存及CPU缓存以外的储存器,一般断电后仍然能保存数据;外存通常是磁性介质或光盘,像硬盘,软盘,磁带,CD等,能长期保存信息,并且不依赖于电来保存信息,但是由机械部件带动,速度与CPU相比就显得慢的多。

不够用。虽然4G内存足够满足Windows 10系统的安装需求,但问题是不可能只在电脑里安装一个系统,还要安装其他应用,而这些应用也会占用一定的内存空间;先不考虑CPU、硬盘和显卡等配件是否能够满足需求,只单独说内存,假设用户安装的Windows 10系统占用了2G内存,但其他的辅助插件和应用可能还会占去2G内存,一旦内存被占满,必然会导致电脑出现卡顿、运行慢的情况。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
