{"id":5504,"date":"2024-11-14T08:15:42","date_gmt":"2024-11-14T00:15:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5504\/"},"modified":"2024-11-14T08:15:42","modified_gmt":"2024-11-14T00:15:42","slug":"mysql%e6%80%8e%e4%b9%88%e4%bd%bf%e7%94%a8%e7%b4%a2%e5%bc%95%e6%9f%a5%e8%af%a2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5504\/","title":{"rendered":"mysql\u600e\u4e48\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2"},"content":{"rendered":"<blockquote><p>\n  \u7d22\u5f15\u5728 mysql \u4e2d\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u6570\u636e\uff0c\u901a\u8fc7\u521b\u5efa\u7d22\u5f15\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002\u53ef\u4ee5\u901a\u8fc7\u5728 create table \u6216 alter table \u8bed\u53e5\u4e2d\u4f7f\u7528 index \u6216 key \u5b50\u53e5\u6765\u521b\u5efa\u7d22\u5f15\u3002\u7d22\u5f15\u7c7b\u578b\u5305\u62ec\uff1ab-tree \u7d22\u5f15\u3001hash \u7d22\u5f15\u548c fulltext \u7d22\u5f15\u3002\u7d22\u5f15\u901a\u8fc7\u5b58\u50a8\u5217\u503c\u7684\u526f\u672c\u548c\u6307\u5411\u5b9e\u9645\u6570\u636e\u884c\u7684\u6307\u9488\u6765\u5de5\u4f5c\u3002\u4f7f\u7528\u7d22\u5f15\u7684\u597d\u5904\u5305\u62ec\u63d0\u9ad8\u67e5\u8be2\u901f\u5ea6\u3001\u964d\u4f4e i\/o \u64cd\u4f5c\u548c\u63d0\u9ad8\u5e76\u53d1\u6027\u3002\u7136\u800c\uff0c\u521b\u5efa\u548c\u7ef4\u62a4\u7d22\u5f15\u4e5f\u5b58\u5728\u5f00\u9500\uff0c\u5e76\u53ef\u80fd\u589e\u52a0\u63d2\u5165\u548c\u66f4\u65b0\u6210\u672c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052905152595975.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u4e2d\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2<\/strong><\/p>\n<p>\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u548c\u68c0\u7d22\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u3002\u901a\u8fc7\u521b\u5efa\u7d22\u5f15\uff0c\u53ef\u4ee5\u663e\u8457\u4f18\u5316\u67e5\u8be2\u6027\u80fd\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2<\/strong><\/p>\n<p>\u5728 MySQL \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728 CREATE TABLE \u6216 ALTER TABLE \u8bed\u53e5\u4e2d\u4f7f\u7528 INDEX \u6216 KEY \u5b50\u53e5\u6765\u521b\u5efa\u7d22\u5f15\u3002<\/p>\n<pre>CREATE TABLE table_name (\n  id INT NOT NULL,\n  name VARCHAR(255) NOT NULL,\n  INDEX(name)\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u8bed\u53e5\u5c06\u4e3a\u8868 table_name \u4e2d\u7684 name \u5217\u521b\u5efa\u7d22\u5f15\u3002<\/p>\n<p><strong>\u7d22\u5f15\u7c7b\u578b\u7684\u9009\u62e9<\/strong><\/p>\n<p>MySQL \u63d0\u4f9b\u4e86\u591a\u79cd\u7d22\u5f15\u7c7b\u578b\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li> <strong>B-Tree \u7d22\u5f15\uff1a<\/strong>\u4e00\u79cd\u5e73\u8861\u6811\u7ed3\u6784\u7684\u7d22\u5f15\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u548c\u8303\u56f4\u67e5\u8be2\u3002<\/li>\n<li> <strong>Hash \u7d22\u5f15\uff1a<\/strong>\u4e00\u79cd\u54c8\u5e0c\u8868\u7ed3\u6784\u7684\u7d22\u5f15\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u76f8\u7b49\u67e5\u8be2\u3002<\/li>\n<li> <strong>Fulltext \u7d22\u5f15\uff1a<\/strong>\u4e00\u79cd\u7528\u4e8e\u5168\u6587\u641c\u7d22\u7684\u7d22\u5f15\u3002<\/li>\n<\/ul>\n<p><strong>\u7d22\u5f15\u5de5\u4f5c\u539f\u7406<\/strong><\/p>\n<p>\u7d22\u5f15\u5145\u5f53\u6570\u636e\u8868\u7684\u76ee\u5f55\uff0c\u5b58\u50a8\u5217\u503c\u7684\u526f\u672c\u548c\u6307\u5411\u5b9e\u9645\u6570\u636e\u884c\u7684\u6307\u9488\u3002\u5f53\u6267\u884c\u67e5\u8be2\u65f6\uff0cMySQL \u5c06\u9996\u5148\u68c0\u67e5\u7d22\u5f15\uff0c\u4ee5\u67e5\u627e\u4e0e\u67e5\u8be2\u6761\u4ef6\u76f8\u5339\u914d\u7684\u6570\u636e\u884c\u3002\u5982\u679c\u7d22\u5f15\u4e2d\u627e\u5230\u5339\u914d\u9879\uff0cMySQL \u5c06\u4f7f\u7528\u6307\u9488\u76f4\u63a5\u83b7\u53d6\u5b9e\u9645\u6570\u636e\u884c\uff0c\u800c\u65e0\u9700\u626b\u63cf\u6574\u4e2a\u8868\u3002<\/p>\n<p><strong>\u7d22\u5f15\u7684\u4f18\u70b9<\/strong><\/p>\n<p>\u4f7f\u7528\u7d22\u5f15\u53ef\u4ee5\u5e26\u6765\u4ee5\u4e0b\u597d\u5904\uff1a<\/p>\n<ul>\n<li> <strong>\u63d0\u9ad8\u67e5\u8be2\u901f\u5ea6\uff1a<\/strong>\u7d22\u5f15\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u67e5\u8be2\u6240\u9700\u7684\u65f6\u95f4\u3002<\/li>\n<li> <strong>\u964d\u4f4e I\/O \u64cd\u4f5c\uff1a<\/strong>\u7d22\u5f15\u901a\u8fc7\u51cf\u5c11\u9700\u8981\u626b\u63cf\u7684\u6570\u636e\u91cf\u6765\u964d\u4f4e I\/O \u64cd\u4f5c\u3002<\/li>\n<li> <strong>\u63d0\u9ad8\u5e76\u53d1\u6027\uff1a<\/strong>\u7d22\u5f15\u6709\u52a9\u4e8e\u63d0\u9ad8\u5e76\u53d1\u6027\uff0c\u56e0\u4e3a\u591a\u4e2a\u4f1a\u8bdd\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u7d22\u5f15\u6765\u83b7\u53d6\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><strong>\u7d22\u5f15\u7684\u7f3a\u70b9<\/strong><\/p>\n<p>\u4f7f\u7528\u7d22\u5f15\u4e5f\u6709\u4e00\u4e9b\u7f3a\u70b9\uff1a<\/p>\n<ul>\n<li> <strong>\u521b\u5efa\u548c\u7ef4\u62a4\u5f00\u9500\uff1a<\/strong>\u521b\u5efa\u548c\u7ef4\u62a4\u7d22\u5f15\u9700\u8981\u989d\u5916\u7684\u7a7a\u95f4\u548c\u5904\u7406\u65f6\u95f4\u3002<\/li>\n<li> <strong>\u63d2\u5165\u548c\u66f4\u65b0\u6210\u672c\uff1a<\/strong>\u6bcf\u6b21\u63d2\u5165\u6216\u66f4\u65b0\u6570\u636e\u65f6\uff0c\u7d22\u5f15\u90fd\u9700\u8981\u66f4\u65b0\uff0c\u8fd9\u4f1a\u589e\u52a0\u64cd\u4f5c\u6210\u672c\u3002<\/li>\n<li> <strong>\u8fc7\u591a\u7684\u7d22\u5f15\uff1a<\/strong>\u521b\u5efa\u8fc7\u591a\u7684\u7d22\u5f15\u4f1a\u51cf\u6162\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u7684\u901f\u5ea6\uff0c\u5e76\u589e\u52a0\u6570\u636e\u5e93\u7a7a\u95f4\u4f7f\u7528\u91cf\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d22\u5f15\u5728 mysql \u4e2d\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u6570\u636e\uff0c\u901a\u8fc7\u521b\u5efa\u7d22\u5f15\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002\u53ef\u4ee5\u901a\u8fc7\u5728 create table \u6216 alter table \u8bed\u53e5\u4e2d\u4f7f\u7528 index \u6216 key \u5b50\u53e5\u6765\u521b\u5efa\u7d22\u5f15\u3002\u7d22\u5f15\u7c7b\u578b\u5305\u62ec\uff1ab-tree \u7d22\u5f15\u3001hash \u7d22\u5f15\u548c fulltext \u7d22\u5f15\u3002\u7d22\u5f15\u901a\u8fc7\u5b58\u50a8\u5217\u503c\u7684\u526f\u672c\u548c\u6307\u5411\u5b9e\u9645\u6570\u636e\u884c\u7684\u6307\u9488\u6765\u5de5\u4f5c\u3002\u4f7f\u7528\u7d22\u5f15\u7684\u597d\u5904\u5305\u62ec\u63d0\u9ad8\u67e5\u8be2\u901f\u5ea6\u3001\u964d\u4f4e i\/o \u64cd\u4f5c\u548c\u63d0\u9ad8\u5e76\u53d1\u6027\u3002\u7136\u800c\uff0c\u521b\u5efa\u548c\u7ef4\u62a4\u7d22\u5f15\u4e5f\u5b58\u5728\u5f00\u9500\uff0c\u5e76\u53ef\u80fd\u589e\u52a0\u63d2\u5165\u548c\u66f4\u65b0\u6210\u672c\u3002 MySQL \u4e2d\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2 \u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u548c\u68c0\u7d22\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u3002\u901a\u8fc7\u521b\u5efa\u7d22\u5f15\uff0c\u53ef\u4ee5\u663e\u8457\u4f18\u5316\u67e5\u8be2\u6027\u80fd\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u3002 \u5982\u4f55\u4f7f\u7528\u7d22\u5f15\u67e5\u8be2 \u5728 MySQL \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728 CREATE TABLE \u6216 ALTER TABLE \u8bed\u53e5\u4e2d\u4f7f\u7528 INDEX \u6216 KEY \u5b50\u53e5\u6765\u521b\u5efa\u7d22\u5f15\u3002 CREATE TABLE table_name ( id INT NOT NULL, name VARCHAR(255) NOT NULL, INDEX(name) ); \u767b\u5f55\u540e\u590d\u5236 \u6b64\u8bed\u53e5\u5c06\u4e3a\u8868 table_name \u4e2d\u7684 name [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5504","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5504"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5504\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}