InnoDB和MyISAM都是密集索引?_MySQL
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了InnoDB和MyISAM都是密集索引?_MySQL,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3557字,纯文字阅读大概需要6分钟。
内容图文
![InnoDB和MyISAM都是密集索引?_MySQL](/upload/InfoBanner/zyjiaocheng/572/ef4dc1d08bbd49f29a9d8804d1f3792c.jpg)
2 找时间研究下,mark一下先。
3 mysql> show create table uniq_id/G
4 *************************** 1. row ***************************
5 Table: uniq_id
6 Create Table: CREATE TABLE `uniq_id` (
7 `id` int(11) DEFAULT NULL,
8 KEY `id` (`id`)
9 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
10 1 row in set (0.00 sec)
11
12 mysql> show create table same_id/G
13 *************************** 1. row ***************************
14 Table: same_id
15 Create Table: CREATE TABLE `same_id` (
16 `id` int(11) DEFAULT NULL,
17 KEY `id` (`id`)
18 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
19 1 row in set (0.00 sec)
20
21 mysql> select count(*),count(distinct id) from same_id;
22 +----------+--------------------+
23 | count(*) | count(distinct id) |
24 +----------+--------------------+
25 | 1000000 | 1 |
26 +----------+--------------------+
27 1 row in set (0.21 sec)
28
29 mysql> alter table uniq_id add index(id);
30 Query OK, 1000000 rows affected (1.27 sec)
31 Records: 1000000 Duplicates: 0 Warnings: 0
32
33 mysql> alter table same_id add index(id);
34 Query OK, 1000000 rows affected (1.59 sec)
35 Records: 1000000 Duplicates: 0 Warnings: 0
36
37 -rw-rw---- 1 mysql mysql 11326464 May 26 10:54 same_id.MYI
38 -rw-rw---- 1 mysql mysql 11326464 May 26 10:54 uniq_id.MYI
39
40 mysql> alter table uniq_id engine=innodb;
41 Query OK, 1000000 rows affected (8.89 sec)
42 Records: 1000000 Duplicates: 0 Warnings: 0
43
44 mysql> alter table same_id engine=innodb;
45 Query OK, 1000000 rows affected (8.48 sec)
46 Records: 1000000 Duplicates: 0 Warnings: 0
47
48 -rw-rw---- 1 mysql mysql 58720256 May 26 10:56 same_id.ibd
49 -rw-rw---- 1 mysql mysql 58720256 May 26 10:56 uniq_id.ibd
50
51 mysql> show create table uniq_id2/G
52 *************************** 1. row ***************************
53 Table: uniq_id2
54 Create Table: CREATE TABLE `uniq_id2` (
55 `id` int(11) NOT NULL,
56 `v` int(11) DEFAULT NULL,
57 PRIMARY KEY (`id`)
58 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
59 1 row in set (0.00 sec)
60
61 mysql> show create table same_id2/G
62 *************************** 1. row ***************************
63 Table: same_id2
64 Create Table: CREATE TABLE `same_id2` (
65 `id` int(11) NOT NULL,
66 `v` int(11) DEFAULT NULL,
67 PRIMARY KEY (`id`)
68 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
69 1 row in set (0.00 sec)
70
71
72 -rw-rw---- 1 mysql mysql 10263552 May 26 11:00 same_id2.MYI
73 -rw-rw---- 1 mysql mysql 10263552 May 26 11:01 uniq_id2.MYI
74
75 mysql> alter table same_id2 add index(v);
76 Query OK, 1000000 rows affected (9.06 sec)
77 Records: 1000000 Duplicates: 0 Warnings: 0
78
79 mysql> alter table uniq_id2 add index(v);
80 Query OK, 1000000 rows affected (8.60 sec)
81 Records: 1000000 Duplicates: 0 Warnings: 0
82
83 -rw-rw---- 1 mysql mysql 21605376 May 26 11:02 same_id2.MYI
84 -rw-rw---- 1 mysql mysql 21605376 May 26 11:02 uniq_id2.MYI
85
86 mysql> alter table uniq_id2 engine=innodb;
87 Query OK, 1000000 rows affected (7.66 sec)
88 Records: 1000000 Duplicates: 0 Warnings: 0
89
90 mysql> alter table same_id2 engine=innodb;
91 Query OK, 1000000 rows affected (8.19 sec)
92 Records: 1000000 Duplicates: 0 Warnings: 0
93
94 -rw-rw---- 1 mysql mysql 54525952 May 26 11:05 same_id2.ibd
95 -rw-rw---- 1 mysql mysql 54525952 May 26 11:05 uniq_id2.ibd
欢迎上网易彩票买彩票啊~
内容总结
以上是互联网集市为您收集整理的InnoDB和MyISAM都是密集索引?_MySQL全部内容,希望文章能够帮你解决InnoDB和MyISAM都是密集索引?_MySQL所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。