{"id":7298,"date":"2024-11-14T09:54:32","date_gmt":"2024-11-14T01:54:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7298\/"},"modified":"2024-11-14T09:54:32","modified_gmt":"2024-11-14T01:54:32","slug":"mysql-%e5%88%a0%e9%99%a4%e6%95%b0%e6%8d%ae%e6%97%b6%e4%bd%95%e6%97%b6%e4%bc%9a%e8%b5%b0%e8%81%94%e5%90%88%e7%b4%a2%e5%bc%95%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7298\/","title":{"rendered":"MySQL \u5220\u9664\u6570\u636e\u65f6\u4f55\u65f6\u4f1a\u8d70\u8054\u5408\u7d22\u5f15\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173069101933824.jpg\" class=\"aligncenter\" title=\"MySQL \u5220\u9664\u6570\u636e\u65f6\u4f55\u65f6\u4f1a\u8d70\u8054\u5408\u7d22\u5f15\uff1f\u63d2\u56fe\" alt=\"MySQL \u5220\u9664\u6570\u636e\u65f6\u4f55\u65f6\u4f1a\u8d70\u8054\u5408\u7d22\u5f15\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u5220\u9664\u6570\u636e\u65f6\u8d70\u7d22\u5f15\u7684\u6761\u4ef6<\/strong><\/p>\n<p>\u5728\u4e00\u4e2a\u7528\u6237\u8868\u4e2d\u6709\u5b57\u6bb5 id\u3001name\u3001age\u3001sex\u3001work \u548c city\uff0c\u8054\u5408\u7d22\u5f15\u4e3a (sex, city)\u3002\u73b0\u5728\u8981\u5220\u9664 sex=\u7537\u3001city=\u5317\u4eac \u7684\u6570\u636e\uff0c\u4f1a\u4e0d\u4f1a\u4f7f\u7528\u8054\u5408\u7d22\u5f15\uff1f<\/p>\n<p><strong>\u56de\u7b54\uff1a<\/strong><\/p>\n<p>\u5728 mysql \u4e2d\uff0c\u5f53\u6d89\u53ca\u7684\u6570\u636e\u91cf\u8d85\u8fc7 20% \u65f6\uff0c\u4e0d\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002\u56e0\u6b64\uff0c\u5982\u679c\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u91cf\u8d85\u8fc7\u8868\u603b\u6570\u636e\u91cf\u7684 20%\uff0c\u5219\u4e0d\u4f1a\u8d70\u7d22\u5f15\u3002<\/p>\n<p><strong>\u5b9e\u8df5\u9a8c\u8bc1\uff1a<\/strong><\/p>\n<ul>\n<li>\u8868\u603b\u6570\u636e\u91cf\uff1a1602 \u6761<\/li>\n<li>\n<p>\u7b26\u5408\u6761\u4ef6\uff08sex, city\uff09\u6761\u6570\uff1a<\/p>\n<ul>\n<li>\u5973\uff0c\u5e7f\u5dde\uff1a604 \u6761<\/li>\n<li>\u5973\uff0c\u60e0\u5dde\uff1a6 \u6761<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u6267\u884c\u5220\u9664\u8bed\u53e5\u7684 expln \u7ed3\u679c\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u5973\uff0c\u5e7f\u5dde\uff1a\u7b26\u5408\u6761\u4ef6\u6570\u636e\u91cf\u8d85\u8fc7 20%\uff0c<\/strong>\u4e0d\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002<\/p>\n<pre>explain delete from  test_del_idx where sex=\"\u5973\" and city = \"\u5e7f\u5dde\";<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd4\u56de\u7ed3\u679c\uff1a<\/p>\n<\/li>\n<\/ul>\n<pre>+----+-------------+--------------+------------+------+---------------+------+---------+------+------+----------+-------------+\n| id | select_type | table        | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | extra       |\n+----+-------------+--------------+------------+------+---------------+------+---------+------+------+----------+-------------+\n|  1 | delete      | test_del_idx | null       | all  | idx_sex_city  | null | null    | null | 1602 |   100.00 | using where |\n+----+-------------+--------------+------------+------+---------------+------+---------+------+------+----------+-------------+<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p><strong>\u5973\uff0c\u60e0\u5dde\uff1a\u7b26\u5408\u6761\u4ef6\u6570\u636e\u91cf\u5c11\u4e8e 20%\uff0c<\/strong>\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002<\/p>\n<pre>explain delete from  test_del_idx where sex=\"\u5973\" and city = \"\u60e0\u5dde\";<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p>\u8fd4\u56de\u7ed3\u679c\uff1a<\/p>\n<pre>+----+-------------+--------------+------------+-------+---------------+--------------+---------+-------------+------+----------+-------------+\n| id | select_type | table        | partitions | type  | possible_keys | key          | key_len | ref         | rows | filtered | Extra       |\n+----+-------------+--------------+------------+-------+---------------+--------------+---------+-------------+------+----------+-------------+\n|  1 | DELETE      | test_del_idx | NULL       | range | idx_sex_city  | idx_sex_city | 773     | const,const |    6 |   100.00 | Using where |\n+----+-------------+--------------+------------+-------+---------------+--------------+---------+-------------+------+----------+-------------+<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u5220\u9664\u6570\u636e\u65f6\u4f55\u65f6\u4f1a\u8d70\u8054\u5408\u7d22\u5f15\uff1f\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>\u5220\u9664\u6570\u636e\u65f6\u8d70\u7d22\u5f15\u7684\u6761\u4ef6 \u5728\u4e00\u4e2a\u7528\u6237\u8868\u4e2d\u6709\u5b57\u6bb5 id\u3001name\u3001age\u3001sex\u3001work \u548c city\uff0c\u8054\u5408\u7d22\u5f15\u4e3a (sex, city)\u3002\u73b0\u5728\u8981\u5220\u9664 sex=\u7537\u3001city=\u5317\u4eac \u7684\u6570\u636e\uff0c\u4f1a\u4e0d\u4f1a\u4f7f\u7528\u8054\u5408\u7d22\u5f15\uff1f \u56de\u7b54\uff1a \u5728 mysql \u4e2d\uff0c\u5f53\u6d89\u53ca\u7684\u6570\u636e\u91cf\u8d85\u8fc7 20% \u65f6\uff0c\u4e0d\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002\u56e0\u6b64\uff0c\u5982\u679c\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u91cf\u8d85\u8fc7\u8868\u603b\u6570\u636e\u91cf\u7684 20%\uff0c\u5219\u4e0d\u4f1a\u8d70\u7d22\u5f15\u3002 \u5b9e\u8df5\u9a8c\u8bc1\uff1a \u8868\u603b\u6570\u636e\u91cf\uff1a1602 \u6761 \u7b26\u5408\u6761\u4ef6\uff08sex, city\uff09\u6761\u6570\uff1a \u5973\uff0c\u5e7f\u5dde\uff1a604 \u6761 \u5973\uff0c\u60e0\u5dde\uff1a6 \u6761 \u6267\u884c\u5220\u9664\u8bed\u53e5\u7684 expln \u7ed3\u679c\uff1a \u5973\uff0c\u5e7f\u5dde\uff1a\u7b26\u5408\u6761\u4ef6\u6570\u636e\u91cf\u8d85\u8fc7 20%\uff0c\u4e0d\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002 explain delete from test_del_idx where sex=&#8221;\u5973&#8221; and city = &#8220;\u5e7f\u5dde&#8221;; \u767b\u5f55\u540e\u590d\u5236 \u8fd4\u56de\u7ed3\u679c\uff1a +&#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;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+ | id | select_type | table | partitions | type | possible_keys [&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-7298","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7298","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=7298"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7298\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}