{"id":923209,"date":"2024-07-01T07:00:51","date_gmt":"2024-07-01T07:00:51","guid":{"rendered":"https:\/\/proxyelite.info\/?p=923209"},"modified":"2024-06-25T07:03:20","modified_gmt":"2024-06-25T07:03:20","slug":"understanding-indexes-in-databases","status":"publish","type":"post","link":"https:\/\/proxyelite.info\/cn\/understanding-indexes-in-databases\/","title":{"rendered":"\u4e86\u89e3\u6570\u636e\u5e93\u4e2d\u7684\u7d22\u5f15"},"content":{"rendered":"<p class=\"wp-block-paragraph\">\u7d22\u5f15\u662f\u5173\u7cfb\u6570\u636e\u5e93\u7684\u57fa\u672c\u7ec4\u6210\u90e8\u5206\uff0c\u65e8\u5728\u63d0\u9ad8\u6570\u636e\u68c0\u7d22\u64cd\u4f5c\u7684\u901f\u5ea6\u3002\u5b83\u4eec\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u901a\u8fc7\u63d0\u4f9b\u5bf9\u8868\u4e2d\u884c\u7684\u5feb\u901f\u8bbf\u95ee\u6765\u63d0\u9ad8\u6570\u636e\u5e93\u67e5\u8be2\u7684\u6548\u7387\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d22\u5f15\u5982\u4f55\u5de5\u4f5c<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u7684\u4f5c\u7528\u7c7b\u4f3c\u4e8e\u4e66\u4e2d\u7684\u7d22\u5f15\u3002\u6570\u636e\u5e93\u65e0\u9700\u626b\u63cf\u6574\u4e2a\u8868\u6765\u67e5\u627e\u6240\u9700\u6570\u636e\uff0c\u800c\u662f\u4f7f\u7528\u7d22\u5f15\u5feb\u901f\u627e\u5230\u6240\u9700\u7684\u884c\u3002\u7d22\u5f15\u901a\u5e38\u521b\u5efa\u5728 WHERE \u5b50\u53e5\u3001JOIN \u6761\u4ef6\u548c ORDER BY \u5b50\u53e5\u4e2d\u7ecf\u5e38\u4f7f\u7528\u7684\u5217\u4e0a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7d22\u5f15\u7ed3\u6784<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u901a\u5e38\u4ee5 B \u6811\u6216\u54c8\u5e0c\u8868\u7684\u5f62\u5f0f\u5b9e\u73b0\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>B \u6811<\/strong>\uff1a\u5e73\u8861\u6811\u7ed3\u6784\uff0c\u4fdd\u6301\u6392\u5e8f\u987a\u5e8f\u5e76\u5141\u8bb8\u641c\u7d22\u3001\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u7684\u5bf9\u6570\u65f6\u95f4\u590d\u6742\u5ea6\u3002<\/li>\n\n\n\n<li><strong>\u54c8\u5e0c\u8868<\/strong>\uff1a\u4e3a\u641c\u7d22\u64cd\u4f5c\u63d0\u4f9b\u6052\u5b9a\u7684\u65f6\u95f4\u590d\u6742\u5ea6\uff0c\u4f46\u5bf9\u4e8e\u8303\u56f4\u67e5\u8be2\u800c\u8a00\uff0c\u5176\u7075\u6d3b\u6027\u4e0d\u5982 B \u6811\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d22\u5f15\u7c7b\u578b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u6709\u591a\u79cd\u7c7b\u578b\uff0c\u6bcf\u79cd\u7c7b\u578b\u90fd\u6709\u4e0d\u540c\u7684\u7528\u9014\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e3b\u7d22\u5f15<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e3b\u7d22\u5f15<\/strong>\uff1a\u5b9a\u4e49\u4e3b\u952e\u65f6\u81ea\u52a8\u521b\u5efa\u3002\u5b83\u552f\u4e00\u5730\u6807\u8bc6\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e8c\u7ea7\u7d22\u5f15<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e8c\u7ea7\u7d22\u5f15<\/strong>\uff1a\u5728\u975e\u4e3b\u952e\u5217\u4e0a\u521b\u5efa\uff0c\u4ee5\u63d0\u9ad8\u6d89\u53ca\u8fd9\u4e9b\u5217\u7684\u67e5\u8be2\u7684\u6027\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u552f\u4e00\u7d22\u5f15<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u552f\u4e00\u7d22\u5f15<\/strong>\uff1a\u786e\u4fdd\u7d22\u5f15\u5217\u5305\u542b\u552f\u4e00\u503c\uff0c\u9632\u6b62\u91cd\u590d\u6761\u76ee\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u7efc\u5408\u6307\u6570<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7efc\u5408\u6307\u6570<\/strong>\uff1a\u591a\u5217\u4e0a\u7684\u7d22\u5f15\uff0c\u5bf9\u4e8e\u57fa\u4e8e\u591a\u5217\u8fdb\u884c\u8fc7\u6ee4\u6216\u6392\u5e8f\u7684\u67e5\u8be2\u5f88\u6709\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5168\u6587\u7d22\u5f15<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5168\u6587\u7d22\u5f15<\/strong>\uff1a\u4e13\u4e3a\u5728\u5927\u578b\u6587\u672c\u5b57\u6bb5\u4e2d\u8fdb\u884c\u9ad8\u6548\u7684\u6587\u672c\u641c\u7d22\u800c\u8bbe\u8ba1\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f4d\u56fe\u7d22\u5f15<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f4d\u56fe\u7d22\u5f15<\/strong>\uff1a\u5bf9\u4e8e\u5177\u6709\u6709\u9650\u6570\u91cf\u4e0d\u540c\u503c\u7684\u5217\u5f88\u6709\u6548\uff0c\u901a\u5e38\u7528\u4e8e\u6570\u636e\u4ed3\u5e93\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d22\u5f15\u5bf9 SELECT \u67e5\u8be2\u7684\u5f71\u54cd<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u53ef\u4ee5\u901a\u8fc7\u51cf\u5c11\u626b\u63cf\u7684\u6570\u636e\u91cf\u6765\u663e\u8457\u63d0\u9ad8 SELECT \u67e5\u8be2\u7684\u6027\u80fd\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u66f4\u5feb\u7684\u6570\u636e\u68c0\u7d22<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u53ef\u8ba9\u6570\u636e\u5e93\u5feb\u901f\u627e\u5230\u7b26\u5408\u67e5\u8be2\u6761\u4ef6\u7684\u884c\uff0c\u800c\u65e0\u9700\u8fdb\u884c\u5168\u8868\u626b\u63cf\u3002\u8fd9\u5bf9\u4e8e\u5927\u578b\u8868\u5c24\u5176\u6709\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f8b\u5b50<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8003\u8651\u4e00\u5f20\u684c\u5b50 <code data-no-translation=\"\">employees<\/code> \u5e26\u6709\u5217 <code data-no-translation=\"\">id<\/code>, <code data-no-translation=\"\">name<\/code>\uff0c \u548c <code data-no-translation=\"\">department<\/code>\u67e5\u627e\u7279\u5b9a\u90e8\u95e8\u7684\u5458\u5de5\u7684\u67e5\u8be2\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code data-no-translation=\"\">SELECT * FROM employees WHERE department = &#39;Sales&#39;;\n<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ca1\u6709\u7d22\u5f15 <code data-no-translation=\"\">department<\/code> \u5217\uff0c\u6570\u636e\u5e93\u4f1a\u626b\u63cf\u6574\u4e2a\u8868\u3002\u6709\u4e86\u7d22\u5f15\uff0c\u5b83\u5c31\u80fd\u5feb\u901f\u627e\u5230\u76f8\u5173\u884c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u51cf\u5c11 I\/O \u64cd\u4f5c<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u51cf\u5c11\u4e86\u4ece\u78c1\u76d8\u83b7\u53d6\u6570\u636e\u6240\u9700\u7684 I\/O \u64cd\u4f5c\u6570\uff0c\u4ece\u800c\u52a0\u5feb\u4e86\u67e5\u8be2\u6267\u884c\u901f\u5ea6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d22\u5f15\u5bf9 INSERT\u3001UPDATE\u3001DELETE \u64cd\u4f5c\u7684\u5f71\u54cd<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u867d\u7136\u7d22\u5f15\u53ef\u4ee5\u63d0\u9ad8 SELECT \u67e5\u8be2\u6027\u80fd\uff0c\u4f46\u5b83\u4eec\u53ef\u80fd\u4f1a\u5bf9\u6570\u636e\u4fee\u6539\u64cd\u4f5c\u7684\u6027\u80fd\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u63d2\u5165\u64cd\u4f5c\u901f\u5ea6\u8f83\u6162<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u63d2\u5165\u65b0\u884c\u65f6\uff0c\u6570\u636e\u5e93\u5fc5\u987b\u66f4\u65b0\u7d22\u5f15\u4ee5\u5305\u542b\u65b0\u6761\u76ee\u3002\u6b64\u989d\u5916\u6b65\u9aa4\u53ef\u80fd\u4f1a\u51cf\u6162\u63d2\u5165\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f8b\u5b50<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ba9\u65b0\u5458\u5de5\u52a0\u5165 <code data-no-translation=\"\">employees<\/code> \u684c\u5b50\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code data-no-translation=\"\">INSERT INTO employees (id, name, department) VALUES (101, &#39;John Doe&#39;, &#39;Sales&#39;);\n<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u6709\u4e00\u4e2a\u7d22\u5f15 <code data-no-translation=\"\">department<\/code> \u5217\uff0c\u6570\u636e\u5e93\u5fc5\u987b\u66f4\u65b0\u7d22\u5f15\uff0c\u8fd9\u4f1a\u589e\u52a0\u63d2\u5165\u8fc7\u7a0b\u7684\u5f00\u9500\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u66f4\u65b0\u64cd\u4f5c\u8f83\u6162<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u66f4\u65b0\u7d22\u5f15\u5217\u9700\u8981\u6570\u636e\u5e93\u66f4\u65b0\u76f8\u5e94\u7684\u7d22\u5f15\u6761\u76ee\u3002\u8fd9\u4f1a\u51cf\u6162\u66f4\u65b0\u8fc7\u7a0b\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e\u5177\u6709\u8bb8\u591a\u7d22\u5f15\u7684\u5927\u578b\u8868\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5220\u9664\u64cd\u4f5c\u901f\u5ea6\u8f83\u6162<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0e\u66f4\u65b0\u7c7b\u4f3c\uff0c\u5220\u9664\u884c\u9700\u8981\u6570\u636e\u5e93\u4ece\u7d22\u5f15\u4e2d\u5220\u9664\u76f8\u5e94\u7684\u6761\u76ee\uff0c\u8fd9\u589e\u52a0\u4e86\u5220\u9664\u8fc7\u7a0b\u7684\u5f00\u9500\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528\u7d22\u5f15\u7684\u6743\u8861<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a7a\u95f4\u5f00\u9500<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u9700\u8981\u989d\u5916\u7684\u5b58\u50a8\u7a7a\u95f4\u3002\u8868\u7684\u7d22\u5f15\u8d8a\u591a\uff0c\u5b58\u50a8\u5b83\u4eec\u6240\u9700\u7684\u78c1\u76d8\u7a7a\u95f4\u5c31\u8d8a\u5927\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7ef4\u62a4\u8d39\u7528<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6570\u636e\u4fee\u6539\uff08INSERT\u3001UPDATE\u3001DELETE\uff09\u671f\u95f4\u7ef4\u62a4\u7d22\u5f15\u4f1a\u589e\u52a0\u5f00\u9500\uff0c\u53ef\u80fd\u4f1a\u51cf\u6162\u8fd9\u4e9b\u64cd\u4f5c\u7684\u901f\u5ea6\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7d22\u5f15\u788e\u7247<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u7d22\u5f15\u53ef\u80fd\u4f1a\u53d8\u5f97\u788e\u7247\u5316\uff0c\u4ece\u800c\u5bfc\u81f4\u6027\u80fd\u4e0b\u964d\u3002\u9700\u8981\u5b9a\u671f\u8fdb\u884c\u7ef4\u62a4\uff0c\u4f8b\u5982\u91cd\u5efa\u6216\u91cd\u7ec4\u7d22\u5f15\uff0c\u4ee5\u4fdd\u6301\u6700\u4f73\u6027\u80fd\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528\u7d22\u5f15\u7684\u6700\u4f73\u5b9e\u8df5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u9009\u62e9\u6027\u7d22\u5f15<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ec5\u5728\u67e5\u8be2\u4e2d\u7ecf\u5e38\u4f7f\u7528\u7684\u5217\u4e0a\u521b\u5efa\u7d22\u5f15\u3002\u907f\u514d\u5bf9\u9009\u62e9\u6027\u8f83\u4f4e\u7684\u5217\uff08\u5177\u6709\u8bb8\u591a\u91cd\u590d\u503c\u7684\u5217\uff09\u521b\u5efa\u7d22\u5f15\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u76d1\u63a7\u4e0e\u7ef4\u62a4<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b9a\u671f\u76d1\u63a7\u7d22\u5f15\u7684\u6027\u80fd\u5e76\u6267\u884c\u7ef4\u62a4\u4efb\u52a1\uff0c\u4f8b\u5982\u91cd\u5efa\u788e\u7247\u7d22\u5f15\uff0c\u4ee5\u786e\u4fdd\u6700\u4f73\u6027\u80fd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7efc\u5408\u6307\u6570<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u57fa\u4e8e\u591a\u5217\u8fdb\u884c\u8fc7\u6ee4\u6216\u6392\u5e8f\u7684\u67e5\u8be2\uff0c\u8bf7\u8003\u8651\u4f7f\u7528\u590d\u5408\u7d22\u5f15\u3002\u4f46\u662f\uff0c\u8bf7\u6ce8\u610f\u590d\u5408\u7d22\u5f15\u4e2d\u5217\u7684\u987a\u5e8f\uff0c\u56e0\u4e3a\u5b83\u4f1a\u5f71\u54cd\u7d22\u5f15\u7684\u6548\u7387\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u907f\u514d\u8fc7\u5ea6\u7d22\u5f15<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u867d\u7136\u7d22\u5f15\u53ef\u4ee5\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\uff0c\u4f46\u8fc7\u5ea6\u7d22\u5f15\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5927\u91cf\u7684\u7ef4\u62a4\u5f00\u9500\u3002\u52aa\u529b\u5728\u67e5\u8be2\u6027\u80fd\u548c\u7ef4\u62a4\u6210\u672c\u4e4b\u95f4\u53d6\u5f97\u5e73\u8861\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ed3\u8bba<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u662f\u4f18\u5316\u6570\u636e\u5e93\u6027\u80fd\u7684\u5f3a\u5927\u5de5\u5177\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e SELECT \u67e5\u8be2\u800c\u8a00\u3002\u5b83\u4eec\u63d0\u4f9b\u5bf9\u6570\u636e\u7684\u5feb\u901f\u8bbf\u95ee\u5e76\u51cf\u5c11\u5bf9\u5168\u8868\u626b\u63cf\u7684\u9700\u6c42\u3002\u4f46\u662f\uff0c\u5b83\u4eec\u4e5f\u4f1a\u4e3a\u6570\u636e\u4fee\u6539\u64cd\u4f5c\u5e26\u6765\u5f00\u9500\uff0c\u56e0\u6b64\u9700\u8981\u8c28\u614e\u7ba1\u7406\u4ee5\u907f\u514d\u6027\u80fd\u4e0b\u964d\u3002\u901a\u8fc7\u4e86\u89e3\u6743\u8861\u5229\u5f0a\u5e76\u9075\u5faa\u6700\u4f73\u5b9e\u8df5\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u6709\u6548\u5730\u5229\u7528\u7d22\u5f15\u6765\u63d0\u9ad8\u6570\u636e\u5e93\u5e94\u7528\u7a0b\u5e8f\u7684\u6548\u7387\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>Indexes are fundamental components of relational databases designed to enhance the speed of data retrieval operations. They serve as data structures that improve the efficiency of database queries by providing quick access to rows in a table. How Indexes Work An index works similarly to an index in a book. Instead of scanning the entire [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":923210,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-923209","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles"],"acf":[],"_links":{"self":[{"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/posts\/923209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/comments?post=923209"}],"version-history":[{"count":0,"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/posts\/923209\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/media\/923210"}],"wp:attachment":[{"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/media?parent=923209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/categories?post=923209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/proxyelite.info\/cn\/wp-json\/wp\/v2\/tags?post=923209"}],"curies":[{"name":"\u53ef\u6e7f\u6027\u7c89\u5242","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}