{"id":2579,"date":"2021-10-14T16:23:10","date_gmt":"2021-10-14T23:23:10","guid":{"rendered":"https:\/\/www.xh86.me\/?p=2579"},"modified":"2021-10-14T16:23:10","modified_gmt":"2021-10-14T23:23:10","slug":"mysql-%e7%b4%a2%e5%bc%95%e4%b8%8e%e6%80%a7%e8%83%bd%e8%b0%83%e4%bc%98","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=2579","title":{"rendered":"MySQL \u7d22\u5f15\u4e0e\u6027\u80fd\u8c03\u4f18"},"content":{"rendered":"<p>\u7d22\u5f15\u7528\u4e8e\u5feb\u901f\u627e\u51fa\u5728\u67d0\u4e2a\u5217\u4e2d\u6709\u4e00\u7279\u5b9a\u503c\u7684\u884c,\u5982\u679c\u4e0d\u4f7f\u7528\u7d22\u5f15MySQL\u5fc5\u987b\u4ece\u7b2cl\u6761\u8bb0\u5f55\u5f00\u59cb\u8bfb\u5b8c\u6574\u4e2a\u8868,\u76f4\u5230\u627e\u51fa\u76f8\u5173\u7684\u884c.\u8868\u8d8a\u5927,\u67e5\u8be2\u6570\u636e\u6240\u82b1\u8d39\u7684\u65f6\u95f4\u8d8a\u591a,\u5982\u679c\u8868\u4e2d\u67e5\u8be2\u7684\u5217\u6709\u4e00\u4e2a\u7d22\u5f15,MySQL\u80fd\u5feb\u901f\u5230\u8fbe\u67d0\u4e2a\u4f4d\u7f6e\u53bb\u641c\u5bfb\u6570\u636e\u6587\u4ef6,\u800c\u4e0d\u5fc5\u67e5\u770b\u6240\u6709\u6570\u636e,\u53ef\u52a0\u5feb\u6570\u636e\u67e5\u8be2\u7684\u67e5\u8be2\u901f\u5ea6\u63d0\u9ad8\u6548\u7387,\u7d22\u5f15\u53ef\u5728\u521b\u5efa\u8868\u65f6\u589e\u52a0,\u4e5f\u53ef\u52a8\u6001\u8c03\u6574\u5df2\u6709\u8868.<\/p>\n<p>\u8be5\u7b14\u8bb0\u6587\u5b57\u63cf\u8ff0\u90e8\u5206\u6574\u7406\u4e8e\u300aMySQL 5.7\u4ece\u5165\u95e8\u5230\u7cbe\u901a\u300b\u5176\u76ee\u7684\u662f\u603b\u7ed3\u901a\u7528\u77e5\u8bc6\u70b9\uff0c\u5b66\u4e60\u65f6\u603b\u7ed3\u7684\u7b14\u8bb0\uff0c\u4ee5\u53ca\u5e38\u7528SQL\u8bed\u53e5\u7684\u5199\u6cd5\u6a21\u677f\uff0c\u65b9\u4fbf\u540e\u671f\u67e5\u9605\u4e0e\u5de5\u4f5c\u65f6\u4f7f\u7528\u3002<\/p>\n<p>\u901a\u4fd7\u7684\u6765\u8bf4\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784,\u662f\u5e2e\u52a9MySQL\u8fdb\u884c\u9ad8\u6548\u68c0\u7d22\u6570\u636e\u7684\u4e00\u79cd\u673a\u5236,\u4f60\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u6392\u597d\u5e8f\u7684\u5feb\u901f\u67e5\u627e\u6570\u636e\u7ed3\u6784,<\/p>\n<p>\u7d22\u5f15\u90fd\u662fB+\u6811(\u591a\u8def\u641c\u7d22\u6811)\u7ed3\u6784\u7ec4\u7ec7\u7684\u7d22\u5f15,\u5305\u62ec\u805a\u96c6\u7d22\u5f15,\u590d\u5408\u7d22\u5f15,\u524d\u7f00\u7d22\u5f15,\u552f\u4e00\u7d22\u5f15,\u90fd\u662fb+\u6811\u7d22\u5f15.<\/p>\n<p>\u4f18\u52bf\uff1a1.\u63d0\u9ad8\u6570\u636e\u68c0\u7d22\u6548\u7387\uff0c\u964d\u4f4e\u6570\u636e\u5e93IO\u6210\u672c\uff0c\u964d\u4f4eCPU\u6d88\u8017\u3002<br \/>\n\u52a3\u52bf: 2.\u7d22\u5f15\u662f\u4e00\u5f20\u8868\uff0c\u7d22\u5f15\u4e5f\u5360\u7a7a\u95f4\uff0c\u867d\u7136\u63d0\u9ad8\u4e86\u67e5\u8be2\u901f\u5ea6\uff0c\u4f46\u4e5f\u4f1a\u964d\u4f4e\u8868\u7684\u66f4\u65b0\u901f\u5ea6\uff0c\u5982\u679c\u65b0\u52a0\u6570\u636e\uff0c\u7d22\u5f15\u4e5f\u4f1a\u81ea\u52a8\u66f4\u65b0\u3002<\/p>\n<p>CPU\u5728\u9971\u548c\u7684\u65f6\u5019\u4e00\u822c\u53d1\u751f\u5728\u6570\u636e\u88c5\u5165\u5185\u5b58\u6216\u4ece\u78c1\u76d8\u4e0a\u8bfb\u53d6\u6570\u636e\u65f6\u3002<br \/>\nIO\u78c1\u76d8\u5e73\u9759\uff0c\u670d\u52a1\u5668\u786c\u4ef6\u5e73\u9759\u3002<\/p>\n<p>\u521b\u5efa\u666e\u901a\u7d22\u5f15:\u00a0\u5728\u521b\u5efa\u8868\u65f6\u6307\u5b9a\u7d22\u5f15\u7c7b\u578b,\u5982\u4e0b\u5728u_id\u5b57\u6bb5\u6dfb\u52a0\u4e00\u4e2a\u666e\u901a\u7d22\u5f15,\u8be5\u7d22\u5f15\u4f5c\u7528\u53ea\u662f\u52a0\u5bf9\u5feb\u6570\u636e\u7684\u8bbf\u95ee\u901f\u5ea6.<\/p>\n<p>MariaDB [lyshark]&gt; create table book<\/p>\n<p>-&gt; (<\/p>\n<p>-&gt; u_id int not null,<\/p>\n<p>-&gt; u_book varchar(20) not null,<\/p>\n<p>-&gt; index(u_id)<\/p>\n<p>-&gt; );<\/p>\n<p>&#8212; \u4f7f\u7528show index\u8bed\u53e5\u67e5\u770b\u6307\u5b9a\u8868\u4e2d\u521b\u5efa\u7684\u7d22\u5f15<\/p>\n<p>MariaDB [lyshark]&gt; show index from book;<\/p>\n<p>MariaDB [lyshark]&gt; show create table book \\G;<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from book where u_id=1 \\G;<\/p>\n<p>\u521b\u5efa\u552f\u4e00\u7d22\u5f15:\u00a0\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u7684\u4e3b\u8981\u539f\u56e0\u662f\u51cf\u5c11\u67e5\u8be2\u7d22\u5f15\u5217\u64cd\u4f5c\u7684\u6267\u884c\u65f6\u95f4,\u5c24\u5176\u662f\u5bf9\u6bd4\u8f83\u5e9e\u5927\u7684\u6570\u636e\u8868.\u5b83\u4e0e\u524d\u9762\u7684\u666e\u901a\u7d22\u5f15\u7c7b\u4f3c,\u4e0d\u540c\u7684\u5c31\u662f:\u7d22\u5f15\u5217\u7684\u503c\u5fc5\u987b\u552f\u4e00,\u4f46\u5141\u8bb8\u6709\u7a7a\u503c.\u5982\u679c\u662f\u7ec4\u5408\u7d22\u5f15,\u5219\u5217\u503c\u7684\u7ec4\u5408\u5fc5\u987b\u552f\u4e00.<\/p>\n<p>MariaDB [lyshark]&gt; create table table_1<\/p>\n<p>-&gt; (<\/p>\n<p>-&gt; id int not null,<\/p>\n<p>-&gt; name char(30) not null,<\/p>\n<p>-&gt; unique index UniqIdx(id)<\/p>\n<p>-&gt; );<\/p>\n<p>Query OK, 0 rows affected (0.02 sec)<\/p>\n<p>MariaDB [lyshark]&gt; show create table table_1 \\G;<\/p>\n<p>*************************** 1. row ***************************<\/p>\n<p>Table: table_1<\/p>\n<p>Create Table: CREATE TABLE `table_1` (<\/p>\n<p>`id` int(11) NOT NULL,<\/p>\n<p>`name` char(30) NOT NULL,<\/p>\n<p>UNIQUE KEY `UniqIdx` (`id`) #id\u5b57\u6bb5\u5df2\u7ecf\u6210\u529f\u5efa\u7acb\u4e86\u4e00\u4e2a\u540d\u4e3aUniqIdx\u7684\u552f\u4e00\u7d22\u5f15<\/p>\n<p>) ENGINE=InnoDB DEFAULT CHARSET=latin1<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>\u521b\u5efa\u5355\u5217\u7d22\u5f15:\u00a0\u5355\u5217\u7d22\u5f15\u662f\u5728\u6570\u636e\u8868\u4e2d\u7684\u67d0\u4e00\u4e2a\u5b57\u6bb5\u4e0a\u521b\u5efa\u7684\u7d22\u5f15,\u4e00\u4e2a\u8868\u4e2d\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u5355\u5217\u7d22\u5f15.\u524d\u9762\u4e24\u4e2a\u4f8b\u5b50\u4e2d\u521b\u5efa\u7684\u7d22\u5f15\u90fd\u4e3a\u5355\u5217\u7d22\u5f15.<\/p>\n<p>MariaDB [lyshark]&gt; create table table_2<\/p>\n<p>-&gt; (<\/p>\n<p>-&gt; id int not null,<\/p>\n<p>-&gt; name char(50) null,<\/p>\n<p>-&gt; index SingleIdx(name(20))<\/p>\n<p>-&gt; );<\/p>\n<p>Query OK, 0 rows affected (0.03 sec)<\/p>\n<p>&nbsp;<\/p>\n<p>MariaDB [lyshark]&gt; show create table table_2 \\G;<\/p>\n<p>*************************** 1. row ***************************<\/p>\n<p>Table: table_2<\/p>\n<p>Create Table: CREATE TABLE `table_2` (<\/p>\n<p>`id` int(11) NOT NULL,<\/p>\n<p>`name` char(50) DEFAULT NULL,<\/p>\n<p>KEY `SingleIdx` (`name`(20)) #name\u5b57\u6bb5\u4e0a\u5df2\u7ecf\u6210\u529f\u5efa\u7acb\u4e86\u4e00\u4e2a\u5355\u5217\u7d22\u5f15,\u540d\u79f0\u4e3aSingleIdx<\/p>\n<p>) ENGINE=InnoDB DEFAULT CHARSET=latin1<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>\u521b\u5efa\u7ec4\u5408\u7d22\u5f15:\u00a0\u7ec4\u5408\u7d22\u5f15\u5c31\u662f\u5728\u591a\u4e2a\u5b57\u6bb5\u4e0a\u521b\u5efa\u591a\u4e2a\u7d22\u5f15.<\/p>\n<p>MariaDB [lyshark]&gt; create table table_3<\/p>\n<p>-&gt; (<\/p>\n<p>-&gt; id int not null,<\/p>\n<p>-&gt; name char(30) not null,<\/p>\n<p>-&gt; age int not null,<\/p>\n<p>-&gt; info varchar(255),<\/p>\n<p>-&gt; index MultiIdx(id,name,age)<\/p>\n<p>-&gt; );<\/p>\n<p>\u521b\u5efa\u5168\u6587\u7d22\u5f15:\u00a0\u5168\u6587\u7d22\u5f15\u53ef\u4ee5\u7528\u4e8e\u5168\u6587\u641c\u7d22,\u5168\u6587\u7d22\u5f15\u9002\u5408\u7528\u4e8e\u5927\u578b\u6570\u636e\u96c6,\u76ee\u524d\u53ea\u6709MyISAM\u5b58\u50a8\u5f15\u64ce\u652f\u6301FULLTEXT\u7d22\u5f15,\u5e76\u4e14\u53ea\u4e3aCHAR\u3001VARCHAR\u548cTEXT\u5217\u521b\u5efa\u7d22\u5f15.\u7d22\u5f15\u603b\u662f\u5bf9\u6574\u4e2a\u5217\u8fdb\u884c,\u4e0d\u652f\u6301\u5c40\u90e8(\u524d\u7f00)\u7d22\u5f15.<\/p>\n<p>&#8212; \u6ce8\u610f\uff1aMySQL5.7\u9ed8\u8ba4\u5b58\u50a8\u5f15\u64ce\u5ba4\u662fInnoDB,\u5728\u8fd9\u91cc\u6211\u4eec\u8981\u6539\u6210MyISAM,\u4e0d\u7136\u7d22\u5f15\u4f1a\u62a5\u9519<\/p>\n<p>MariaDB [lyshark]&gt; create table table_4(<\/p>\n<p>-&gt; id int not null,<\/p>\n<p>-&gt; name char(40) not null,<\/p>\n<p>-&gt; age int not null,<\/p>\n<p>-&gt; info varchar(255),<\/p>\n<p>-&gt; fulltext index FullTxtIdx(info)<\/p>\n<p>-&gt; )engine=MyISAM;<\/p>\n<p>\u521b\u5efa\u7a7a\u95f4\u7d22\u5f15:\u00a0\u7a7a\u95f4\u7d22\u5f15\u5fc5\u987b\u5728MyISAM\u7c7b\u578b\u7684\u8868\u4e2d\u521b\u5efa,\u4e14\u7a7a\u95f4\u7c7b\u578b\u7684\u5b57\u6bb5\u5fc5\u987b\u4e3a\u7a7a,\u53ef\u4ee5\u770b\u5230,table_5\u8868\u7684g\u5b57\u6bb5\u4e0a\u521b\u5efa\u4e86\u540d\u79f0\u4e3aspatIdex\u7684\u7a7a\u95f4\u7d22\u5f15,\u6ce8\u610f:\u521b\u5efa\u65f6\u95f4\u6307\u5b9a\u7a7a\u95f4\u7c7b\u578b\u5b57\u6bb5\u503c\u7684\u975e\u7a7a\u7ea6\u675f,\u5e76\u4e14\u8868\u7684\u5b58\u50a8\u5f15\u64ce\u5fc5\u987b\u4e3aMyISAM.<\/p>\n<p>MariaDB [lyshark]&gt; create table table_5<\/p>\n<p>-&gt; (<\/p>\n<p>-&gt; g geometry not null,<\/p>\n<p>-&gt; spatial index spatIdx(g)<\/p>\n<p>-&gt; )engine=MyISAM;<\/p>\n<p>\u6dfb\u52a0\u7d22\u5f15:\u00a0\u4e0a\u9762\u7684\u51e0\u79cd\u5f62\u5f0f\u90fd\u662f\u5728\u65b0\u5efa\u8868\u4e2d\u6dfb\u52a0\u7d22\u5f15,\u5982\u679c\u9700\u8981\u5728\u5df2\u5b58\u5728\u8868\u4e2d\u6dfb\u52a0\u5219\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e86.<\/p>\n<p>MariaDB [lyshark]&gt; create table book<\/p>\n<p>-&gt; (<\/p>\n<p>-&gt; bookid int not null,<\/p>\n<p>-&gt; bookname varchar(255) not null,<\/p>\n<p>-&gt; authors varchar(255) not null,<\/p>\n<p>-&gt; info varchar(255) null,<\/p>\n<p>-&gt; comment varchar(255) null,<\/p>\n<p>-&gt; year_public year not null<\/p>\n<p>-&gt; );<\/p>\n<p>&#8212; \u6dfb\u52a0\u666e\u901a\u7d22\u5f15<\/p>\n<p>MariaDB [lyshark]&gt; alter table book add index BKNameIdx(bookname(30));<\/p>\n<p>&#8212; \u6dfb\u52a0\u552f\u4e00\u7d22\u5f15<\/p>\n<p>MariaDB [lyshark]&gt; alter table book add unique index UniqidIdx(bookId);<\/p>\n<p>&#8212; \u6dfb\u52a0\u5355\u5217\u7d22\u5f15<\/p>\n<p>MariaDB [lyshark]&gt; alter table book add index BkcmtIdx(comment(50));<\/p>\n<p>&#8212; \u6dfb\u52a0\u7ec4\u5408\u7d22\u5f15<\/p>\n<p>MariaDB [lyshark]&gt; alter table book add index BkAuAndInfoIdx(authors(30),info(50));<\/p>\n<p>&#8212; \u901a\u8fc7\u7d22\u5f15\u540d\u5b57\u5220\u9664\u7d22\u5f15<\/p>\n<p>MariaDB [lyshark]&gt; alter table book drop index UniqidIdx;<\/p>\n<p>MariaDB [lyshark]&gt; alter table book drop index BKNameIdx;<\/p>\n<p>explain \u5b57\u6bb5\u7684\u60c5\u51b5:<\/p>\n<p>MariaDB [lyshark]&gt; explain select s_name,s_city from suppliers where s_id IN (select Gid from lyshark where Uid=&#8217;a1&#8242;);<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| 1 | PRIMARY | lyshark | const | PRIMARY | PRIMARY | 30 | const | 1 | |<\/p>\n<p>| 1 | PRIMARY | suppliers | const | PRIMARY | PRIMARY | 4 | const | 1 | |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>MariaDB [lyshark]&gt; explain select Course.CID,Course.Cname from Course join(<\/p>\n<p>select CID from lyshark.StudentScore where SID = (select SID from lyshark.Student where Sname=&#8217;\u5468\u6885&#8217;)<\/p>\n<p>)as StudentScore on Course.CID = StudentScore.CID;<\/p>\n<p>+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;-+<\/p>\n<p>| 1(1) | SIMPLE | Course | ALL | NULL | NULL | NULL | NULL | 3 | |<\/p>\n<p>| 1(2) | SIMPLE | StudentScore | ALL | NULL | NULL | NULL | NULL | 18 | |<\/p>\n<p>| 3 | SUBQUERY | Student | ALL | NULL | NULL | NULL | NULL | 10 | |<\/p>\n<p>+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;-+<\/p>\n<p>ID\u5b57\u6bb5\u7684\u7406\u89e3:<\/p>\n<p>1.\u5f53ID\u5b57\u6bb5\u76f8\u540c\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u6570\u636e\u662f\u4ece\u4e0a\u5230\u4e0b,\u4f8b\u5982\u7b2c\u4e00\u5f20\u8868\u4e2d\u4f1a\u7531\u4e0a\u81f3\u4e0b\u6267\u884c\u4e0b\u6765.<\/p>\n<p>2.\u5f53ID\u4e0d\u540c\u7684\u60c5\u51b5,\u5982\u679c\u662f\u5b50\u67e5\u8be2,id\u8d8a\u5927\u7684\u5c06\u5728\u6700\u524d\u9762\u88ab\u6267\u884c,\u4f8b\u5982\u7b2c\u4e8c\u5f20\u8868\u6267\u884c\u987a\u5e8f\u4e3a3-&gt;1(1)-&gt;1(2)<\/p>\n<p>select_type<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from tbl_emp a left join tbl_dept b on a.deptld=b.id where b.id is null<\/p>\n<p>-&gt; union<\/p>\n<p>-&gt; select * from tbl_emp a right join tbl_dept b on a.deptld = b.id where a.deptld is null;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+<\/p>\n<p>| 1 | PRIMARY | a | ALL | NULL | NULL | NULL | NULL | 8 | |<\/p>\n<p>| 1 | PRIMARY | b | eq_ref | PRIMARY | PRIMARY | 4 | lyshark.a.deptld | 1 | |<\/p>\n<p>| 2 | UNION | b | ALL | NULL | NULL | NULL | NULL | 5 | |<\/p>\n<p>| 2 | UNION | a | ALL | fk_dept_id | NULL | NULL | NULL | 8 | |<\/p>\n<p>| NULL | UNION RESULT | &lt;union1,2&gt; | ALL | NULL | NULL | NULL | NULL | NULL | |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+<\/p>\n<p>SIMPLE =&gt; \u6807\u5fd7\u7740\u7b80\u5355\u7684select\u67e5\u8be2\u8bf7\u6c42,\u67e5\u8be2\u4e2d\u4e0d\u5305\u542b\u5b50\u67e5\u8be2\u6216\u8005union\u67e5\u8be2.<\/p>\n<p>PRIMARY =&gt; \u67e5\u8be2\u4e2d\u4efb\u4f55\u590d\u6742\u7684\u67e5\u8be2\u4e2d,\u6700\u5916\u5c42\u7684\u67e5\u8be2\u8bed\u53e5,\u5c31\u662f\u6700\u540e\u52a0\u8f7d\u7684\u8bed\u53e5.<\/p>\n<p>SUBQUERY =&gt; \u5b50\u67e5\u8be2\u7c7b\u578b,\u5728select\u6216where\u5217\u8868\u4e2d\u5305\u542b\u4e86\u5b50\u67e5\u8be2.<\/p>\n<p>DERIVED =&gt; \u5728FROM\u5217\u8868\u4e2d\u5305\u542b\u5b50\u67e5\u8be2,\u4f1a\u88ab\u6807\u8bb0\u4e3aDERIVED(\u884d\u751f),\u6b64\u65f6\u4f1a\u9012\u5f52\u6267\u884c\u5b50\u67e5\u8be2,\u5e76\u5b58\u50a8\u5728\u4e34\u65f6\u8868\u4e2d.<\/p>\n<p>UNION =&gt; \u82e5\u7b2c\u4e8c\u4e2aSELECT\u51fa\u73b0\u5728UNION\u4e4b\u540e,\u5219\u6807\u8bb0\u4e3aUNION.<\/p>\n<p>UNION RESULT =&gt; \u4eceUNION\u8868\u4e2d\u83b7\u53d6\u7ed3\u679c\u7684SELECT<\/p>\n<p>type \u8bbf\u95ee\u7c7b\u578b\u6392\u5217\uff0c\u53ea\u8981\u80fd\u591f\u8fbe\u5230ref\uff0crange\u7ea7\u522b\u5c31\u5df2\u7ecf\u4e0d\u9519\u4e86\uff0c\u6027\u80fd\u6548\u7387\u3002<\/p>\n<p>system -&gt; const -&gt; eq_ref -&gt; ref -&gt; range -&gt;index -&gt; all<\/p>\n<p>system -&gt; \u8868\u4e2d\u53ea\u6709\u4e00\u6761\u8bb0\u5f55\uff0c\u8fd9\u662fconst\u7c7b\u578b\u7684\u7279\u91cc\uff0c\u5e73\u65f6\u4e0d\u4f1a\u51fa\u73b0\u3002<\/p>\n<p>const -&gt; \u4e3b\u952e\u552f\u4e00\u7d22\u5f15\uff1a\u8868\u793a\u901a\u8fc7\u7d22\u5f15\u4e00\u6b21\u5c31\u627e\u5230\u6570\u636e\uff0c\u4f8b\u5982\u67e5\u8be2\u4e00\u4e2a\u5e38\u91cf\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from lyshark where Uid=&#8221;a1&#8243;;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| 1 | SIMPLE | lyshark | const | PRIMARY | PRIMARY | 30 | const | 1 | |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>eq_ref -&gt; \u552f\u4e00\u6027\u7d22\u5f15\u626b\u63cf\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u7d22\u5f15\u952e\uff0c\u8868\u4e2d\u53ea\u6709\u4e00\u6761\u8bb0\u5f55\u4e0e\u4e4b\u5339\u914d\uff0c\u5e38\u7528\u4e8e\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\u626b\u63cf\u3002<\/p>\n<p>ref-&gt; \u975e\u552f\u4e00\u6027\u7d22\u5f15\u626b\u63cf\uff0c\u8fd4\u56de\u5339\u914d\u67d0\u4e2a\u5355\u72ec\u503c\u7684\u6240\u6709\u884c\uff0c\u88ab\u4e4b\u4e0a\u4e5f\u662f\u4e00\u79cd\u7d22\u5f15\u8bbf\u95ee\u3002\u67e5\u627e\u626b\u63cf\u6df7\u5408\u4f53<\/p>\n<p>MariaDB [lyshark]&gt; create table t1(col1 int,col2 int);<\/p>\n<p>MariaDB [lyshark]&gt; alter table t1 add index idx_col1_col2(col1,col2);<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from t1 where col1=1;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8211;+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8211;+<\/p>\n<p>| 1 | SIMPLE | t1 | ref | idx_col1_col2 | idx_col1_col2 | 5 | const | 1 | |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8211;+<\/p>\n<p>range -&gt; \u8303\u56f4\u626b\u63cf\uff0c\u53ea\u68c0\u7d22\u7ed9\u5b9a\u8303\u56f4\u7684\u884c\uff0ckey\u5217\u663e\u793a\u4f7f\u7528\u4e86\u90a3\u4e2a\u7d22\u5f15\u3002 where\uff0cbetween\uff0c&lt;&gt;\uff0cin \u7b49\u67e5\u8be2\u4e2d\u4f7f\u7528\u3002<\/p>\n<p>explain select * from t1 where col1 between 1 and 2;<\/p>\n<p>explain select * from t1 where col1 in (1,2,3);<\/p>\n<p>index -&gt; \u5168\u7d22\u5f15\u626b\u63cf\uff0c\u5168\u8868\u7d22\u5f15\u626b\u63cf\uff0c\u6bd4all\u8981\u597d\u4e00\u4e9b\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from t1;<\/p>\n<p>all -&gt; \u5168\u8868\u626b\u63cf\u3002\u6700\u5dee\u7684\u6027\u80fd\u3002<\/p>\n<p>possible_keys\uff0ckey \u662f\u5426\u4f7f\u7528\u5230\u4e86\u7d22\u5f15\uff0cpossible_keys \u663e\u793a\u53ef\u80fd<\/p>\n<p>possible_keys =&gt; \u663e\u793a\u53ef\u80fd\u5e94\u7528\u5728\u8fd9\u5f20\u8868\u4e2d\u7684\u7d22\u5f15\uff0c\u4e00\u4e2a\u6216\u591a\u4e2a\uff0c\u8be5\u7d22\u5f15\u4f1a\u88ab\u5217\u51fa\uff0c\u4f46\u4e0d\u4e00\u5b9a\u88ab\u5b9e\u9645\u67e5\u8be2\u4f7f\u7528\u3002<\/p>\n<p>key =&gt; \u5b9e\u9645\u5e94\u7528\u5230\u672c\u6b21\u67e5\u8be2\u7684\u7d22\u5f15\u7c7b\u578b\u3002\u6700\u91cd\u8981\u7684\u3002\u5982\u679c\u4e3aNULL\uff0c\u5219\u8bf4\u660e\u6ca1\u6709\u4f7f\u7528\u7d22\u5f15\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select col1,col2 from t1;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| 1 | SIMPLE | t1 | index | NULL | idx_col1_col2 | 10 | NULL | 1 | |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>\u67e5\u8be2\u4e2d\u82e5\u4f7f\u7528\u4e86\u8986\u76d6\u7d22\u5f15\uff0c\u5219\u8be5\u7d22\u5f15\u4ec5\u51fa\u73b0key\u5217\u8868\u4e2d \u8986\u76d6\u7d22\u5f15\u4ee5\u4e0b\u5c31\u662f\u539f\u7406<\/p>\n<p>MariaDB [lyshark]&gt; create table t1(col1 int,col2 int,col3 int);<\/p>\n<p>MariaDB [lyshark]&gt; alter table t1 add index idx_col1_col2(col1,col2);<\/p>\n<p>&#8212; \u5efa\u7acb\u7684\u7d22\u5f15\u4e0e\uff0c\u67e5\u8be2\u7684\u884c\u6570\uff0c\u5fc5\u987b\u4e00\u81f4\uff0ccol1,col2\u662f\u6709\u7d22\u5f15\u7684\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select col1,col2 from t1;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>| 1 | SIMPLE | t1 | index | NULL | idx_col1_col2 | 10 | NULL | 1 | Using |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>&#8212; \u626b\u63cf\u4e09\u4e2a\u503c\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4f7f\u7528\u7d22\u5f15\u7684\u60c5\u51b5\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select col1,col2,col3 from t1;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 1 | |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>possible_keys\uff0ckey,ken_len<\/p>\n<p>key_len \u8868\u793a\u7d22\u5f15\u4e2d\u4f7f\u7528\u7684\u5b57\u8282\u6570\uff0c\u8fd9\u4e2a\u957f\u5ea6\u7528\u7684\u8d8a\u5c11\u8d8a\u597d\uff0ckenLen\u957f\u5ea6\u662f\u6839\u636e\u8868\u7684\u5b9a\u4e49\u8ba1\u7b97\u5f97\u51fa\uff0c\u800c\u4e0d\u662f\u8868\u4e2d\u6570\u636e\u68c0\u7d22\u51fa\u7684\u3002<\/p>\n<p>ref \u663e\u793a\u7d22\u5f15\u7684\u90a3\u4e00\u5217\u88ab\u4f7f\u7528\u4e86\uff0c\u5982\u679c\u53ef\u80fd\u7684\u8bdd\uff0c\u662f\u4e00\u4e2a\u5e38\u6570\uff0c\u90a3\u4e9b\u5217\u6216\u5e38\u91cf\u88ab\u7528\u4e8e\u67e5\u627e\u7d22\u5f15\u5217\u4e0a\u7684\u503c\u3002\u5b9a\u4e49\u4e86\u5f15\u7528\u4e86\u90a3\u4e9b\u5e93\u3002<\/p>\n<p>rows \u6839\u636e\u8868\u7edf\u8ba1\u4fe1\u606f\u53ca\u7d22\u5f15\u9009\u7528\u60c5\u51b5\uff0c\u5927\u81f4\u4f30\u7b97\u51fa\u627e\u5230\u6240\u9700\u7684\u8bb0\u5f55\u6240\u9700\u8981\u8bfb\u53d6\u7684\u884c\u6570\uff0c\u8be5\u503c\u5f53\u7136\u4e5f\u662f\u8d8a\u5c0f\u8d8a\u597d\u3002 \u6bcf\u5f20\u8868\u6709\u591a\u5c11\u884c\u88ab\u4f18\u5316\u5668\u67e5\u8be2\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from lyshark;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>| 1 | SIMPLE | lyshark | ALL | NULL | NULL | NULL | NULL | 17 | |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>MariaDB [lyshark]&gt; create table tt1(id int primary key,col1 varchar(10),col2 varchar(10));<\/p>\n<p>MariaDB [lyshark]&gt; create table tt2(id int primary key,col1 varchar(10),col2 varchar(10));<\/p>\n<p>MariaDB [lyshark]&gt; create index idt_col1_col2 on tt2(col1,col2);<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from tt1,tt2 where tt1.id = tt2.id and tt2.col1 = &#8216;admin&#8217;;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>| 1 | SIMPLE | tt1 | ALL | PRIMARY | NULL | NULL | NULL | 1 | |<\/p>\n<p>| 1 | SIMPLE | tt2 | eq_ref | PRIMARY,idt_col1_col2 | PRIMARY | 4 | lyshark.tt1.id | 1 | Using where |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>2 rows in set (0.00 sec)<\/p>\n<p>extra \u6269\u5c55\u5217<\/p>\n<p>using filesort \u4ea7\u751f\u4e86\u6587\u4ef6\u5185\u6392\u5e8f\uff0c\u5b8c\u86cb\u4e86\uff0cmysql\u65e0\u6cd5\u4f7f\u7528\u7d22\u5f15\u8fdb\u884c\u6392\u5e8f\uff0c\u4f7f\u7528\u4e86\u5916\u90e8\u7684\u7d22\u5f15\u6392\u5e8f\uff0c\u800c\u4e0d\u662f\u6309\u7167\u8868\u5185\u7684\u7d22\u5f15\u987a\u5e8f\u8fdb\u884c\u8bfb\u53d6\u3002mysql\u65e0\u6cd5\u5229\u7528\u7d22\u5f15\u5b8c\u6210\u6392\u5e8f\uff0c\u64cd\u4f5c\u6210\u4e3a\u6587\u4ef6\u6392\u5e8f\u3002<\/p>\n<p>MariaDB [lyshark]&gt; create table tab1(id int primary key,col1 int,col2 int,col3 int);<\/p>\n<p>MariaDB [lyshark]&gt; insert into tab1 values(1,1,2,3),(2,4,5,6),(3,7,8,9);<\/p>\n<p>MariaDB [lyshark]&gt; create index tab1_col1_col2_col3 on tab1(col1,col2,col3);<\/p>\n<p>MariaDB [lyshark]&gt; explain select col1 from tab1 where col1 order by col3 \\G<\/p>\n<p>*************************** 1. row ***************************<\/p>\n<p>id: 1<\/p>\n<p>select_type: SIMPLE<\/p>\n<p>table: tab1<\/p>\n<p>type: index<\/p>\n<p>possible_keys: tab1_col1_col2_col3<\/p>\n<p>key: tab1_col1_col2_col3<\/p>\n<p>key_len: 15<\/p>\n<p>ref: NULL<\/p>\n<p>rows: 3<\/p>\n<p>Extra: Using where; Using index; Using filesort<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>MariaDB [lyshark]&gt; explain select col1 from tab1 where col1 order by col2,col3 \\G<\/p>\n<p>\u67e5\u8be2\u4f7f\u7528\u7d22\u5f15\uff0c\u6ca1\u95ee\u9898\u7684\uff0c\u53ea\u662f\u8bf4\uff0c\u6211\u4eec\u6ca1\u6709\u9488\u5bf9order by \u5efa\u7acb\u6392\u5e8f\u7d22\u5f15\uff0c\u6216\u8005\u662f\u5efa\u7acb\u4e86\u7d22\u5f15\uff0c\u4f60\u6ca1\u7528\u4e0a\uff01\uff01<\/p>\n<p>\u4ee5\u4e0b\u6211\u4eec\u52a0\u4e0a\u5168\u90e8\u7d22\u5f15\u5b57\u6bb5\uff0c\u4ece\u6b64\u4e0b\u9762\u8fd9\u6761sql\u6027\u80fd\u66f4\u9ad8\u4e86\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select col1 from tab1 where col1 order by col1,col2,col3 \\G<\/p>\n<p>*************************** 1. row ***************************<\/p>\n<p>id: 1<\/p>\n<p>select_type: SIMPLE<\/p>\n<p>table: tab1<\/p>\n<p>type: index<\/p>\n<p>possible_keys: tab1_col1_col2_col3<\/p>\n<p>key: tab1_col1_col2_col3<\/p>\n<p>key_len: 15<\/p>\n<p>ref: NULL<\/p>\n<p>rows: 3<\/p>\n<p>Extra: Using where; Using index<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>\u5982\u679c\u53ef\u4ee5\uff0c\u5c3d\u5feb\u4f18\u5316\u3002<\/p>\n<p>using temporary \u5f7b\u5e95\u5b8c\u728a\u5b50\uff0c\u8fd9\u4e2a\u4f1a\u65b0\u5efa\u4e86\u4e00\u4e2a\u5185\u90e8\u4e34\u65f6\u8868\uff0c\u7136\u540e\u64cd\u4f5c\u5b8c\u540e\u518d\u628a\u4e34\u65f6\u8868\u5220\u9664\uff0c\u52a8\u4f5c\u66f4\u51f6\u9669\u3002<\/p>\n<p>\u4f7f\u7528\u4e34\u65f6\u8868\u4fdd\u5b58\u4e2d\u95f4\u7ed3\u679c\uff0cmysql\u5728\u5bf9\u67e5\u8be2\u7ed3\u679c\u6392\u5e8f\u65f6\u4f7f\u7528\u4e34\u65f6\u8868\uff0c\u5e38\u7528\u4e8e\u6392\u5e8forder by \u548c\u5206\u7ec4\u67e5\u8be2group by .<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from tab1 where col1 in(1,2,3) group by col2 \\G<\/p>\n<p>*************************** 1. row ***************************<\/p>\n<p>id: 1<\/p>\n<p>select_type: SIMPLE<\/p>\n<p>table: tab1<\/p>\n<p>type: index<\/p>\n<p>possible_keys: tab1_col1_col2_col3<\/p>\n<p>key: tab1_col1_col2_col3<\/p>\n<p>key_len: 15<\/p>\n<p>ref: NULL<\/p>\n<p>rows: 3<\/p>\n<p>Extra: Using where; Using index; Using temporary; Using filesort \u5f7b\u5e95\u5b8c\u728a\u5b50<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\uff0c\u4f60\u7ed9\u6211\u5efa\u7acb\u7684\u7d22\u5f15\u4e2a\u6570\u548c\u987a\u5e8f\uff0c\u4e00\u5b9a\u8981\u6309\u987a\u5e8f\u6765\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from tab1 where col1 in(1,2,3) group by col1,col2 \\G<\/p>\n<p>*************************** 1. row ***************************<\/p>\n<p>id: 1<\/p>\n<p>select_type: SIMPLE<\/p>\n<p>table: tab1<\/p>\n<p>type: index<\/p>\n<p>possible_keys: tab1_col1_col2_col3<\/p>\n<p>key: tab1_col1_col2_col3<\/p>\n<p>key_len: 15<\/p>\n<p>ref: NULL<\/p>\n<p>rows: 3<\/p>\n<p>Extra: Using where; Using index \u89e3\u51b3\u4e86\u3002<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>using index \u8fd9\u79cd\u60c5\u51b5\u662f\u597d\u4e8b\uff0c\u8868\u793a\u76f8\u5e94\u7684\u64cd\u4f5c\u4f7f\u7528\u4e86 covering index \u4f7f\u7528\u4e86\u8986\u76d6\u7d22\u5f15\uff0c\u6548\u7387\u4e0d\u9519\uff0c\u3002<\/p>\n<p>\u5982\u679c\u540c\u65f6\u51fa\u73b0\u4e86using where \u8868\u793a\u7d22\u5f15\u88ab\u7528\u6765\u6267\u884c\u7d22\u5f15\u952e\u503c\u7684\u67e5\u627e\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u540c\u65f6\u51fa\u73b0using where \u8868\u660e\u7d22\u5f15\u7528\u6765\u8bfb\u53d6\u6570\u636e\u800c\u975e\u6267\u884c\u67e5\u627e\u52a8\u4f5c\u3002<\/p>\n<p>MariaDB [lyshark]&gt; explain select col1,col2 from tab1;<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>| 1 | SIMPLE | tab1 | index | NULL | tab1_col1_col2_col3 | 15 | NULL | 3 | Using index | using \u8868\u660e\u76f4\u63a5\u4ece\u7d22\u5f15\u4e0a\u627e\u5230\u4e86\u6570\u636e\u3002<\/p>\n<p>+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>\u8986\u76d6\u7d22\u5f15\uff0c\u5c31\u662f\u8bf4\u4f60\u5efa\u7acb\u7684\u590d\u5408\u7d22\u5f15\u662f x,y,z \u90a3\u4e48\u4f60\u5728\u67e5\u8be2\u662f\u5e94\u8be5\u8981\u8986\u76d6\u8fd9\u4e9b\u7d22\u5f15\uff0c\u8fd9\u6837\u624d\u80fd\u8ba9\u7d22\u5f15\uff0c\u53d1\u6325\u5176\u6700\u5927\u7684\u6027\u80fd\uff0c\u5426\u5219\u7d22\u5f15\u7b49\u4e8e\u767d\u5efa\u7acb\u3002<\/p>\n<p>\u8986\u76d6\u7d22\u5f15\uff0c\u5c3d\u91cf\u4e0d\u8981\u5199\u661f\u53f7\uff0c\u8fd9\u79cd\u4f4e\u6548\u7387\u7684\u67e5\u8be2\u3002<\/p>\n<p>select * from lyshark where id=1; &#8212; \u5b8c\u86cb\u7684\u3002<\/p>\n<p>select x,y,z from lyshark wehre id =1; &#8212; \u8986\u76d6\u5230\u4e3b\u952e\u4e0a\uff0c\u67e5\u8be2\u6548\u7387\u63d0\u5347\u5f88\u591a\u3002<\/p>\n<p>using where -&gt; \u4f7f\u7528\u4e86where using join buffer -&gt; \u7528\u5230\u4e86\u7f13\u5b58buffer<\/p>\n<p>\u5b9e\u73b0\u5355\u8868\u7d22\u5f15\u4f18\u5316<\/p>\n<p>create table if not exists article(<\/p>\n<p>id int(10) unsigned not null primary key auto_increment,<\/p>\n<p>author_id int(10) unsigned not null,<\/p>\n<p>category_id int(10) unsigned not null,<\/p>\n<p>views int(10) unsigned not null,<\/p>\n<p>comments int(10) unsigned not null,<\/p>\n<p>title varbinary(255) not null,<\/p>\n<p>content text not null );<\/p>\n<p>insert into article(author_id,category_id,views,comments,title,content) values(1,1,1,1,&#8217;1&#8242;,&#8217;1&#8242;),(1,1,1,2,&#8217;1&#8242;,&#8217;1&#8242;),(2,2,2,2,&#8217;2&#8242;,&#8217;2&#8242;),(3,3,3,3,&#8217;3&#8242;,&#8217;3&#8242;);<\/p>\n<p>MariaDB [lyshark]&gt; explain select id,author_id from article where category_id=1 and comments&gt;1 order by views desc limit 1;<\/p>\n<p>&#8212; \u521b\u5efa\u590d\u5408\u7d22\u5f15 all \u53d8\u4e3a\u4e86range \u53ea\u89e3\u51b3\u4e86\u5168\u8868\u626b\u63cf\u95ee\u9898<\/p>\n<p>MariaDB [lyshark]&gt; create index idx_article_ccv on article(category_id,comments,views);<\/p>\n<p>&#8212; \u6700\u540e\u4e00\u4e2a\u5b8c\u6574\u7248\u7684<\/p>\n<p>MariaDB [lyshark]&gt; drop index idx_article_ccv on article;<\/p>\n<p>MariaDB [lyshark]&gt; create index idx_article_cv on article(category_id,views);<\/p>\n<p>\u5b9e\u73b0\u4e24\u8868\u7d22\u5f15\u4f18\u5316<\/p>\n<p>create table class<\/p>\n<p>(<\/p>\n<p>id int(10) auto_increment,<\/p>\n<p>card int(10) not null,<\/p>\n<p>primary key(id)<\/p>\n<p>);<\/p>\n<p>create table book<\/p>\n<p>(<\/p>\n<p>bookid int(10) auto_increment,<\/p>\n<p>card int(10) not null,<\/p>\n<p>primary key(bookid)<\/p>\n<p>);<\/p>\n<p>MariaDB [lyshark]&gt; insert into class(card) values(floor(1+(rand()*20))); * 10<\/p>\n<p>MariaDB [lyshark]&gt; insert into book(card) values(floor(1+(rand()*20))); * 10<\/p>\n<p>MariaDB [lyshark]&gt; select * from book inner join class on book.card = class.card;<\/p>\n<p>&#8212; \u5de6\u8fde\u63a5\u7684\u7279\u6027\u662f\u5de6\u8868\u5168\u90fd\u6709,\u8fde\u63a5\u53f3\u8868\u7684\u90e8\u5206<\/p>\n<p>&#8212; \u5de6\u53f3\u94fe\u63a5\u603b\u6709\u4e00\u5f20\u8868\u662f\u7528\u6765\u9a71\u52a8\u7684,\u5de6\u8fde\u63a5\u94fe\u63a5\u7684\u662f\u53f3\u8868,\u5982\u4e0b\u5de6\u8868class\u53f3\u8868\u662fbook<\/p>\n<p>MariaDB [lyshark]&gt; select * from class left join book on book.card = class.card;<\/p>\n<p>&#8212; \u5de6\u8fde\u63a5\u60c5\u51b5\u4e0b,\u5c06\u7d22\u5f15\u5efa\u7acb\u5728\u53f3\u8868\u4e0a\u9762\u6548\u7387\u662f\u6700\u9ad8\u7684,\u5982\u4e0b\u53f3\u8868\u662fbook<\/p>\n<p>MariaDB [lyshark]&gt; alter table book add index left_index(card);<\/p>\n<p>&#8212; \u53f3\u94fe\u63a5,\u9700\u8981\u5c06\u7d22\u5f15\u52a0\u5230\u5de6\u8fb9\u8868\u4e0a,\u4e5f\u5c31\u662f\u52a0\u5230class\u8868\u7684card\u5b57\u6bb5\u4e0a.<\/p>\n<p>MariaDB [lyshark]&gt; show index from book;<\/p>\n<p>MariaDB [lyshark]&gt; drop index left_index on book;<\/p>\n<p>MariaDB [lyshark]&gt; select * from class right join book on book.card = class.card;<\/p>\n<p>MariaDB [lyshark]&gt; alter table class add index right_index(card);<\/p>\n<p>\u4e09\u5f20\u8868\u7d22\u5f15\u4f18\u5316<\/p>\n<p>create table phone<\/p>\n<p>(<\/p>\n<p>phoneid int(10) auto_increment,<\/p>\n<p>card int(10) not null,<\/p>\n<p>primary key(phoneid)<\/p>\n<p>);<\/p>\n<p>MariaDB [lyshark]&gt; insert into phone(card) values(floor(1+(rand()*20))); * 10<\/p>\n<p>&#8212; \u6700\u7b80\u5355\u7684\u94fe\u63a5\u67e5\u8be2<\/p>\n<p>MariaDB [lyshark]&gt; select * from class inner join book on class.card=book.card inner join phone on book.card=phone.card;<\/p>\n<p>&#8212; \u5de6\u8fde\u63a5\u67e5\u8be2<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from class left join book on class.card=book.card left join phone on book.card=phone.card;<\/p>\n<p>alter table book add index book_left_index(card);<\/p>\n<p>alter table phone add index phone_left_index(card);<\/p>\n<p>&#8212; join \u8bed\u53e5\u4f18\u5316\u5efa\u8bae<\/p>\n<p>&#8212; 1. \u5c3d\u53ef\u80fd\u51cf\u5c11join\u8bed\u53e5\u4e2d\u7684NestedLoop\u7684\u5faa\u73af\u6b21\u6570: \u6c38\u8fdc\u7528\u5c0f\u7ed3\u679c\u96c6,\u9a71\u52a8\u5927\u7684\u7ed3\u679c\u96c6.<\/p>\n<p>&#8212; 2. \u4f18\u5148\u4f18\u5316NestedLoop\u7684\u5185\u5c42\u5faa\u73af<\/p>\n<p>&#8212; \u4fdd\u8bc1join\u8bed\u53e5\u4e2d\u88ab\u9a71\u52a8\u8868\u4e0ajoin\u6761\u4ef6\u5b57\u6bb5\u5df2\u7ecf\u88ab\u7d22\u5f15.<\/p>\n<p>&#8212; \u5f53\u65e0\u6cd5\u4fdd\u8bc1\u88ab\u9a71\u52a8\u8868\u7684join\u6761\u4ef6\u5b57\u6bb5\u88ab\u7d22\u5f15\u4e14\u5185\u5b58\u8d44\u6e90\u5145\u8db3\u7684\u524d\u63d0\u4e0b,\u4e0d\u8981\u592a\u541d\u60dcjoinbuffer \u7684\u8bbe\u7f6e.<\/p>\n<p>&#8212; \u5982\u679c\u662f\u4e09\u8868,\u5de6\u67e5\u8be2,\u90a3\u4e48\u6211\u4eec\u5e94\u8be5\u5c06\u7d22\u5f15,\u5efa\u7acb\u5728\u5de6\u8fde\u63a5\u8868\u4e2d.<\/p>\n<p>&#8212; \u53f3\u8fde\u63a5\u67e5\u8be2<\/p>\n<p>MariaDB [lyshark]&gt; explain select * from class right join book on class.card=book.card right join phone on book.card=phone.card;<\/p>\n<p>alter table book add index book_left_index(card);<\/p>\n<p>alter table phone add index phone_left_index(card);<\/p>\n<p>\u89e3\u51b3\u4e2d\u6587\u4e71\u7801\u95ee\u9898:<\/p>\n<p>[root@localhost mysql]# cp -a \/usr\/share\/mysql\/my-huge.cnf \/etc\/my.cnf<\/p>\n<p>[root@localhost mysql]# vim \/etc\/my.cnf<\/p>\n<p>[client]<\/p>\n<p>default-character-set=utf8<\/p>\n<p>[mysqld]<\/p>\n<p>character_set_server=utf8<\/p>\n<p>character_set_client=utf8<\/p>\n<p>collation-server=utf8_general_ci<\/p>\n<p>[mysql]<\/p>\n<p>default-character-set=utf8<\/p>\n<p>&#8212; \u67e5\u8be2\u5b57\u7b26\u96c6\u7f16\u7801<\/p>\n<p>MariaDB [lyshark]&gt; select * from information_schema.character_sets;<\/p>\n<p>MariaDB [lyshark]&gt; show character set like &#8216;utf8%&#8217;;<\/p>\n<p>MariaDB [lyshark]&gt; show variables like &#8216;character_set%&#8217;;<\/p>\n<p>&#8212; \u8bbe\u7f6e\u5168\u5c40\u5b57\u7b26\u96c6<\/p>\n<p>set global character_set_client=utf8;<\/p>\n<p>set global character_set_connection=utf8;<\/p>\n<p>set global character_set_database=utf8;<\/p>\n<p>set global character_set_results=utf8;<\/p>\n<p>set global character_set_server=utf8;<\/p>\n<p>&#8212; \u66f4\u65b0\u6307\u5b9a\u8868\u4e3autf8\u683c\u5f0f<\/p>\n<p>MariaDB [lyshark]&gt; alter database lyshark default character set utf8 collate utf8_general_ci;<\/p>\n<p>MariaDB [lyshark]&gt; alter table lyshark.user convert to character set utf8 collate utf8_general_ci;<\/p>\n<p>&#8212; \u9519\u8bef\u65e5\u5fd7<\/p>\n<p>[root@localhost ~]# vim \/etc\/my.cnf<\/p>\n<p>[mysqld]<\/p>\n<p>log-error=&#8221;\/var\/log\/mariadb\/mariadb.log&#8221;<\/p>\n<p>MariaDB [(none)]&gt; show variables like &#8216;log%&#8217;;<\/p>\n<p>[root@localhost ~]# cat \/var\/log\/mariadb\/mariadb.log |head -n 10<\/p>\n<p>MariaDB [(none)]&gt; flush logs;<\/p>\n<p>&#8212; \u4e8c\u8fdb\u5236\u65e5\u5fd7<\/p>\n<p>[root@localhost ~]# vim \/etc\/my.cnf<\/p>\n<p>[mysqld]<\/p>\n<p>log-bin=&#8221;\/tmp&#8221; #\u8bbe\u7f6e\u5f00\u542f\u65e5\u5fd7,\u4e5f\u53ef\u4e0d\u6307\u5b9a\u65e5\u5fd7\u4fdd\u5b58\u4f4d\u7f6e<\/p>\n<p>expire_logs_days = 10 #\u8bbe\u7f6e\u65e5\u5fd7\u81ea\u52a8\u6e05\u7406\u5929\u6570<\/p>\n<p>max_binlog_size = 100M #\u5b9a\u4e49\u4e86\u5355\u4e2a\u6587\u4ef6\u7684\u5927\u5c0f\u9650\u5236<\/p>\n<p>&#8212; \u5220\u9664\u65e5\u5fd7<\/p>\n<p>MariaDB [(none)]&gt; show binary logs;<\/p>\n<p>MariaDB [(none)]&gt; purge master logs to &#8220;mariadb-bin.000001&#8221;;<\/p>\n<p>MariaDB [(none)]&gt; purge master logs before &#8220;20180101&#8221;;<\/p>\n<p>[root@localhost ~]# mysqlbinlog mariadb-bin.000001<\/p>\n<p>&#8212; \u6162\u67e5\u8be2\u65e5\u5fd7<\/p>\n<p>MariaDB [lyshark]&gt; show variables like &#8216;%slow_query_log%&#8217;;<\/p>\n<p>MariaDB [lyshark]&gt; set global slow_query_log=1;<\/p>\n<p>MariaDB [lyshark]&gt; show variables like &#8216;%long_query_time%&#8217;;<\/p>\n<p>MariaDB [lyshark]&gt; set global long_query_time=3;<\/p>\n<p>MariaDB [lyshark]&gt; show global status like &#8216;%Slow_queries%&#8217;;<\/p>\n<p>[root@localhost mysql]# cat \/var\/lib\/mysql\/localhost-slow.log<\/p>\n<p>[root@localhost ~]# vim \/etc\/my.cnf<\/p>\n<p>[mysqld]<\/p>\n<p>log-slow-queries=&#8221;\/var\/lib\/mysql\/localhost-slow.log&#8221;<\/p>\n<p>long_query_time=10<\/p>\n<p>log_output=FILE<\/p>\n<p>-s \u6392\u5e8f\u65b9\u5f0f<\/p>\n<p>-c \u8bbf\u95ee\u6b21\u6570<\/p>\n<p>-l \u9501\u5b9a\u65f6\u95f4<\/p>\n<p>-r \u8fd4\u56de\u8bb0\u5f55<\/p>\n<p>-t \u67e5\u8be2\u65f6\u95f4<\/p>\n<p>-al \u5e73\u5747\u9501\u5b9a\u65f6\u95f4<\/p>\n<p>-ar \u5e73\u5747\u8fd4\u56de\u8bb0\u5f55\u6570<\/p>\n<p>-at \u5e73\u5747\u67e5\u8be2\u65f6\u95f4<\/p>\n<p>-t \u8fd4\u56de\u524d\u9762\u591a\u5c11\u6761\u8bb0\u5f55<\/p>\n<p>-g \u5339\u914d\u6b63\u5219<\/p>\n<p>&#8212; \u5f97\u5230\u8fd4\u56de\u8bb0\u5f55\u96c6\u6700\u591a\u768410\u4e2aSQL<\/p>\n<p>[root@localhost mysql]# mysqldumpslow -s -r -t 10 \/var\/lib\/mysql\/localhost-slow.log<\/p>\n<p>&#8212; \u5f97\u5230\u8bbf\u95ee\u6b21\u6570\u6700\u591a\u768410\u4e2aSQL<\/p>\n<p>[root@localhost mysql]# mysqldumpslow -s -c -t 10 \/var\/lib\/mysql\/localhost-slow.log<\/p>\n<p>&#8212; \u5f97\u5230\u6309\u7167\u65f6\u95f4\u6392\u5e8f\u7684\u524d\u5341\u6761\u91cc\u9762\u542b\u6709\u5de6\u8fde\u63a5\u7684\u67e5\u8be2\u8bed\u53e5.<\/p>\n<p>[root@localhost mysql]# mysqldumpslow -s -t -t 10 -g &#8216;left join&#8217; \/var\/lib\/mysql\/localhost-slow.log<\/p>\n<p>show variables like &#8216;profiling&#8217;;<\/p>\n<p>set profiling=on;<\/p>\n<p>MariaDB [lyshark]&gt; select * from tbl_emp;<\/p>\n<p>MariaDB [lyshark]&gt; show profiles; \/\/ \u67e5\u8be2\u7cfb\u7edf\u4e2d\u6267\u884c\u7684sql<\/p>\n<p>&#8212; \u67e5\u8be23\u53f7\u8bb0\u5f55\u4e2d\u7684\u95ee\u9898\uff0c\u5f97\u52303\u53f7\u8bed\u53e5\u7684\u67e5\u8be2\u751f\u547d\u5468\u671f\u3002<\/p>\n<p>MariaDB [lyshark]&gt; show profile cpu,block io for query 3;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1371\" height=\"385\" class=\"wp-image-2580\" src=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/table-description-automatically-generated-12.png\" alt=\"Table\n\nDescription automatically generated\" srcset=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/table-description-automatically-generated-12.png 1371w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/table-description-automatically-generated-12-300x84.png 300w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/table-description-automatically-generated-12-1024x288.png 1024w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/table-description-automatically-generated-12-768x216.png 768w\" sizes=\"auto, (max-width: 1371px) 100vw, 1371px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1432\" height=\"334\" class=\"wp-image-2581\" src=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/graphical-user-interface-text-application-descr-10.png\" alt=\"Graphical user interface, text, application\n\nDescription automatically generated\" srcset=\"https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/graphical-user-interface-text-application-descr-10.png 1432w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/graphical-user-interface-text-application-descr-10-300x70.png 300w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/graphical-user-interface-text-application-descr-10-1024x239.png 1024w, https:\/\/www.xh86.me\/wp-content\/uploads\/2021\/10\/graphical-user-interface-text-application-descr-10-768x179.png 768w\" sizes=\"auto, (max-width: 1432px) 100vw, 1432px\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d22\u5f15\u7528\u4e8e\u5feb\u901f\u627e\u51fa\u5728\u67d0\u4e2a\u5217\u4e2d\u6709\u4e00\u7279\u5b9a\u503c\u7684\u884c,\u5982\u679c\u4e0d\u4f7f\u7528\u7d22\u5f15MySQL\u5fc5\u987b\u4ece\u7b2cl\u6761\u8bb0\u5f55\u5f00\u59cb\u8bfb\u5b8c\u6574\u4e2a\u8868,\u76f4\u5230\u627e\u51fa\u76f8\u5173 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2579","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2579"}],"version-history":[{"count":1,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2579\/revisions"}],"predecessor-version":[{"id":2582,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2579\/revisions\/2582"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}