{"id":154605,"date":"2024-11-02T17:12:21","date_gmt":"2024-11-02T09:12:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/154605\/"},"modified":"2024-11-02T17:12:22","modified_gmt":"2024-11-02T09:12:22","slug":"%e5%b0%8d-sql-server-%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e6%8c%87%e7%a4%ba%e7%b6%9c%e5%90%88%e6%8f%8f%e8%bf%b0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/154605\/","title":{"rendered":"\u5c0d SQL Server \u805a\u96c6\u7d22\u5f15\u7684\u6307\u793a\u7d9c\u5408\u63cf\u8ff0"},"content":{"rendered":"<h1 id=\"%e5%b0%8d-sql-server-%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e6%8c%87%e7%a4%ba%e7%b6%9c%e5%90%88%e6%8f%8f%e8%bf%b0-srmyOCkSnX\">\u5c0d SQL Server \u805a\u96c6\u7d22\u5f15\u7684\u6307\u793a\u7d9c\u5408\u63cf\u8ff0<\/h1>\n<p>\u5728\u8cc7\u6599\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0c\u7d22\u5f15\u662f\u4e00\u7a2e\u91cd\u8981\u7684\u7d50\u69cb\uff0c\u7528\u65bc\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002SQL Server \u4e2d\u7684\u805a\u96c6\u7d22\u5f15\uff08Clustered Index\uff09\u662f\u6700\u5e38\u7528\u7684\u7d22\u5f15\u985e\u578b\u4e4b\u4e00\u3002\u672c\u6587\u5c07\u5c0d\u805a\u96c6\u7d22\u5f15\u7684\u7279\u6027\u3001\u512a\u52e2\u3001\u4f7f\u7528\u60c5\u5883\u53ca\u5176\u5728 SQL Server \u4e2d\u7684\u5be6\u4f5c\u9032\u884c\u7d9c\u5408\u63cf\u8ff0\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%ef%bc%9f-srmyOCkSnX\">\u4ec0\u9ebc\u662f\u805a\u96c6\u7d22\u5f15\uff1f<\/h2>\n<p>\u805a\u96c6\u7d22\u5f15\u662f\u5c07\u8cc7\u6599\u8868\u4e2d\u7684\u8cc7\u6599\u884c\u6309\u7167\u7d22\u5f15\u9375\u7684\u9806\u5e8f\u9032\u884c\u6392\u5e8f\u7684\u4e00\u7a2e\u7d22\u5f15\u3002\u8207\u975e\u805a\u96c6\u7d22\u5f15\u4e0d\u540c\uff0c\u805a\u96c6\u7d22\u5f15\u6703\u76f4\u63a5\u5f71\u97ff\u8cc7\u6599\u7684\u7269\u7406\u5b58\u5132\u9806\u5e8f\u3002\u6bcf\u500b\u8cc7\u6599\u8868\u53ea\u80fd\u6709\u4e00\u500b\u805a\u96c6\u7d22\u5f15\uff0c\u56e0\u70ba\u8cc7\u6599\u884c\u53ea\u80fd\u6309\u7167\u4e00\u7a2e\u9806\u5e8f\u9032\u884c\u6392\u5e8f\u3002<\/p>\n<h2 id=\"%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e7%89%b9%e6%80%a7-srmyOCkSnX\">\u805a\u96c6\u7d22\u5f15\u7684\u7279\u6027<\/h2>\n<ul>\n<li><strong>\u552f\u4e00\u6027\uff1a<\/strong>\u805a\u96c6\u7d22\u5f15\u7684\u9375\u503c\u5fc5\u9808\u662f\u552f\u4e00\u7684\uff0c\u9019\u6a23\u624d\u80fd\u78ba\u4fdd\u8cc7\u6599\u7684\u552f\u4e00\u6027\u3002<\/li>\n<li><strong>\u6392\u5e8f\uff1a<\/strong>\u8cc7\u6599\u8868\u4e2d\u7684\u8cc7\u6599\u6703\u6839\u64da\u805a\u96c6\u7d22\u5f15\u7684\u9375\u503c\u9032\u884c\u6392\u5e8f\uff0c\u9019\u4f7f\u5f97\u7bc4\u570d\u67e5\u8a62\u7684\u6027\u80fd\u5927\u5e45\u63d0\u5347\u3002<\/li>\n<li><strong>\u5b58\u5132\uff1a<\/strong>\u805a\u96c6\u7d22\u5f15\u7684\u8449\u7bc0\u9ede\u5305\u542b\u4e86\u8cc7\u6599\u884c\u7684\u5be6\u969b\u6578\u64da\uff0c\u9019\u610f\u5473\u8457\u67e5\u8a62\u6642\u4e0d\u9700\u8981\u984d\u5916\u7684\u67e5\u627e\u3002<\/li>\n<\/ul>\n<h2 id=\"%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e5%84%aa%e5%8b%a2-srmyOCkSnX\">\u805a\u96c6\u7d22\u5f15\u7684\u512a\u52e2<\/h2>\n<p>\u805a\u96c6\u7d22\u5f15\u5728\u8a31\u591a\u60c5\u6cc1\u4e0b\u90fd\u80fd\u986f\u8457\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4e3b\u8981\u512a\u52e2\uff1a<\/p>\n<ul>\n<li><strong>\u63d0\u9ad8\u67e5\u8a62\u901f\u5ea6\uff1a<\/strong>\u7531\u65bc\u8cc7\u6599\u662f\u6309\u7167\u7d22\u5f15\u9375\u7684\u9806\u5e8f\u5b58\u5132\uff0c\u7bc4\u570d\u67e5\u8a62\uff08\u4f8b\u5982\u67e5\u8a62\u67d0\u500b\u7bc4\u570d\u5167\u7684\u6578\u64da\uff09\u6703\u66f4\u5feb\u3002<\/li>\n<li><strong>\u6e1b\u5c11 I\/O \u64cd\u4f5c\uff1a<\/strong>\u805a\u96c6\u7d22\u5f15\u7684\u8a2d\u8a08\u4f7f\u5f97\u67e5\u8a62\u6642\u53ef\u4ee5\u76f4\u63a5\u8a2a\u554f\u8cc7\u6599\uff0c\u6e1b\u5c11\u4e86\u5c0d\u78c1\u789f\u7684 I\/O \u64cd\u4f5c\u3002<\/li>\n<li><strong>\u9069\u5408\u6392\u5e8f\u548c\u5206\u7d44\u64cd\u4f5c\uff1a<\/strong>\u5728\u9032\u884c\u6392\u5e8f\u6216\u5206\u7d44\u64cd\u4f5c\u6642\uff0c\u805a\u96c6\u7d22\u5f15\u80fd\u5920\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e4%bd%bf%e7%94%a8%e6%83%85%e5%a2%83-srmyOCkSnX\">\u4f7f\u7528\u60c5\u5883<\/h2>\n<p>\u805a\u96c6\u7d22\u5f15\u9069\u5408\u7528\u65bc\u4ee5\u4e0b\u60c5\u5883\uff1a<\/p>\n<ul>\n<li>\u9700\u8981\u983b\u7e41\u9032\u884c\u7bc4\u570d\u67e5\u8a62\u7684\u8cc7\u6599\u8868\uff0c\u4f8b\u5982\u65e5\u671f\u7bc4\u570d\u67e5\u8a62\u3002<\/li>\n<li>\u8cc7\u6599\u8868\u4e2d\u7684\u67d0\u4e00\u5217\u7d93\u5e38\u7528\u4f5c\u6392\u5e8f\u6216\u5206\u7d44\u7684\u4f9d\u64da\u3002<\/li>\n<li>\u8cc7\u6599\u8868\u7684\u8b80\u53d6\u64cd\u4f5c\u9060\u591a\u65bc\u5beb\u5165\u64cd\u4f5c\u7684\u60c5\u6cc1\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8-sql-server-%e4%b8%ad%e5%89%b5%e5%bb%ba%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95-srmyOCkSnX\">\u5982\u4f55\u5728 SQL Server \u4e2d\u5275\u5efa\u805a\u96c6\u7d22\u5f15<\/h2>\n<p>\u5728 SQL Server \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8a9e\u53e5\u4f86\u5275\u5efa\u805a\u96c6\u7d22\u5f15\uff1a<\/p>\n<pre><code>CREATE CLUSTERED INDEX idx_ColumnName\nON TableName (ColumnName);<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5047\u8a2d\u6709\u4e00\u500b\u540d\u70ba <code>Employees<\/code> \u7684\u8cc7\u6599\u8868\uff0c\u6211\u5011\u5e0c\u671b\u5728 <code>EmployeeID<\/code> \u5217\u4e0a\u5275\u5efa\u805a\u96c6\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u53e5\uff1a<\/p>\n<pre><code>CREATE CLUSTERED INDEX idx_EmployeeID\nON Employees (EmployeeID);<\/code><\/pre>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-srmyOCkSnX\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u4f7f\u7528\u805a\u96c6\u7d22\u5f15\u6642\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u7531\u65bc\u6bcf\u500b\u8cc7\u6599\u8868\u53ea\u80fd\u6709\u4e00\u500b\u805a\u96c6\u7d22\u5f15\uff0c\u56e0\u6b64\u5728\u8a2d\u8a08\u8cc7\u6599\u8868\u6642\u9700\u8981\u8b39\u614e\u9078\u64c7\u7d22\u5f15\u9375\u3002<\/li>\n<li>\u805a\u96c6\u7d22\u5f15\u7684\u66f4\u65b0\u64cd\u4f5c\u53ef\u80fd\u6703\u5c0e\u81f4\u9801\u9762\u5206\u88c2\uff0c\u5f71\u97ff\u6027\u80fd\uff0c\u56e0\u6b64\u5728\u9ad8\u983b\u7387\u7684\u5beb\u5165\u64cd\u4f5c\u4e2d\u9700\u8b39\u614e\u4f7f\u7528\u3002<\/li>\n<li>\u5728\u9078\u64c7\u805a\u96c6\u7d22\u5f15\u7684\u5217\u6642\uff0c\u61c9\u8003\u616e\u5176\u9078\u64c7\u6027\uff0c\u9078\u64c7\u6027\u8d8a\u9ad8\u7684\u5217\u8d8a\u9069\u5408\u7528\u4f5c\u805a\u96c6\u7d22\u5f15\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-srmyOCkSnX\">\u7e3d\u7d50<\/h2>\n<p>\u805a\u96c6\u7d22\u5f15\u5728 SQL Server \u4e2d\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u80fd\u5920\u986f\u8457\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002\u901a\u904e\u5408\u7406\u7684\u8a2d\u8a08\u548c\u4f7f\u7528\uff0c\u805a\u96c6\u7d22\u5f15\u53ef\u4ee5\u5e6b\u52a9\u958b\u767c\u8005\u512a\u5316\u8cc7\u6599\u5eab\u7684\u6027\u80fd\uff0c\u7279\u5225\u662f\u5728\u9700\u8981\u9032\u884c\u5927\u91cf\u67e5\u8a62\u7684\u61c9\u7528\u4e2d\u3002\u5c0d\u65bc\u5c0b\u6c42\u9ad8\u6548\u80fd\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\u7684\u7528\u6236\uff0c\u4e86\u89e3\u805a\u96c6\u7d22\u5f15\u7684\u7279\u6027\u548c\u4f7f\u7528\u60c5\u5883\u5c07\u6709\u52a9\u65bc\u66f4\u597d\u5730\u7ba1\u7406\u548c\u512a\u5316\u8cc7\u6599\u5eab\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3 SQL Server \u805a\u96c6\u7d22\u5f15\u7684\u7279\u6027\u3001\u512a\u52e2\u53ca\u6700\u4f73\u5be6\u8e10\uff0c\u63d0\u5347\u6578\u64da\u67e5\u8a62\u6548\u7387\u8207\u6027\u80fd\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-154605","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/154605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=154605"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/154605\/revisions"}],"predecessor-version":[{"id":154606,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/154605\/revisions\/154606"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=154605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=154605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=154605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}