{"id":7300,"date":"2024-11-14T10:55:01","date_gmt":"2024-11-14T02:55:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7300\/"},"modified":"2024-11-14T10:55:01","modified_gmt":"2024-11-14T02:55:01","slug":"mysql-%e5%88%a0%e9%99%a4%e6%95%b0%e6%8d%ae%e6%97%b6%e6%98%af%e5%90%a6%e4%bc%9a%e5%88%a9%e7%94%a8%e7%b4%a2%e5%bc%95%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7300\/","title":{"rendered":"MySQL \u5220\u9664\u6570\u636e\u65f6\u662f\u5426\u4f1a\u5229\u7528\u7d22\u5f15\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173069231974581.jpg\" class=\"aligncenter\" title=\"MySQL \u5220\u9664\u6570\u636e\u65f6\u662f\u5426\u4f1a\u5229\u7528\u7d22\u5f15\uff1f\u63d2\u56fe\" alt=\"MySQL \u5220\u9664\u6570\u636e\u65f6\u662f\u5426\u4f1a\u5229\u7528\u7d22\u5f15\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u5220\u9664\u6570\u636e\u65f6\u662f\u5426\u5229\u7528\u7d22\u5f15<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0\uff1a<\/strong><\/p>\n<p>\u5728\u62e5\u6709 (sex, city) \u8054\u5408\u7d22\u5f15\u7684 user \u8868\u4e2d\uff0c\u5220\u9664\u6307\u5b9a\u6027\u522b\u548c\u57ce\u5e02\u7684\u6570\u636e\u65f6\uff0c\u662f\u5426\u4f1a\u4f7f\u7528\u8be5\u7d22\u5f15\uff1f<\/p>\n<p><strong>\u7b54\u6848\uff1a<\/strong><\/p>\n<p>\u5728 mysql \u4e2d\uff0c\u5982\u679c\u5220\u9664\u64cd\u4f5c\u6d89\u53ca\u7684\u6570\u636e\u91cf\u8d85\u8fc7 20%\uff0c\u5c06\u4e0d\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002\u5426\u5219\uff0c\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002<\/p>\n<p><strong>\u5b9e\u8df5\u9a8c\u8bc1\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u6570\u636e\u603b\u91cf\u4e3a 1602\uff0c\u5220\u9664\u6ee1\u8db3 sex=&#8221;\u5973&#8221;\u3001city=&#8221;\u5e7f\u5dde&#8221; \u6761\u4ef6\u7684\u6570\u636e\uff0c\u6d89\u53ca\u6570\u636e\u91cf\u4e3a 604\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>\u6267\u884c\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       | all  | idx_sex_city  | null | null    | null | 1602 |   100.00 | using where |\n+---------+---------+--------------+------------+------+---------------+------+---------+------+------+----------+-------------+<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7531\u4e8e\u5220\u9664\u6570\u636e\u91cf\u8d85\u8fc7\u4e86 20%\uff0c\u56e0\u6b64\u672a\u8d70\u7d22\u5f15\u3002<\/p>\n<p>\u518d\u5047\u8bbe\u5220\u9664\u6ee1\u8db3 sex=&#8221;\u5973&#8221;\u3001city=&#8221;\u60e0\u5dde&#8221; \u6761\u4ef6\u7684\u6570\u636e\uff0c\u6d89\u53ca\u6570\u636e\u91cf\u4e3a 6\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 <\/p>\n<p>\u6267\u884c\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>\u7531\u4e8e\u5220\u9664\u6570\u636e\u91cf\u5c11\u4e8e 20%\uff0c\u56e0\u6b64\u8d70\u7d22\u5f15\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u5220\u9664\u6570\u636e\u65f6\u662f\u5426\u4f1a\u5229\u7528\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\u662f\u5426\u5229\u7528\u7d22\u5f15 \u95ee\u9898\u63cf\u8ff0\uff1a \u5728\u62e5\u6709 (sex, city) \u8054\u5408\u7d22\u5f15\u7684 user \u8868\u4e2d\uff0c\u5220\u9664\u6307\u5b9a\u6027\u522b\u548c\u57ce\u5e02\u7684\u6570\u636e\u65f6\uff0c\u662f\u5426\u4f1a\u4f7f\u7528\u8be5\u7d22\u5f15\uff1f \u7b54\u6848\uff1a \u5728 mysql \u4e2d\uff0c\u5982\u679c\u5220\u9664\u64cd\u4f5c\u6d89\u53ca\u7684\u6570\u636e\u91cf\u8d85\u8fc7 20%\uff0c\u5c06\u4e0d\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002\u5426\u5219\uff0c\u4f1a\u4f7f\u7528\u7d22\u5f15\u3002 \u5b9e\u8df5\u9a8c\u8bc1\uff1a \u5047\u8bbe\u6570\u636e\u603b\u91cf\u4e3a 1602\uff0c\u5220\u9664\u6ee1\u8db3 sex=&#8221;\u5973&#8221;\u3001city=&#8221;\u5e7f\u5dde&#8221; \u6761\u4ef6\u7684\u6570\u636e\uff0c\u6d89\u53ca\u6570\u636e\u91cf\u4e3a 604\u3002 explain delete from test_del_idx where sex=&#8221;\u5973&#8221; and city = &#8220;\u5e7f\u5dde&#8221;; \u767b\u5f55\u540e\u590d\u5236 \u6267\u884c\u7ed3\u679c\uff1a +&#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;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | [&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-7300","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7300","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=7300"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7300\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}