{"id":199994,"date":"2025-05-06T11:59:17","date_gmt":"2025-05-06T03:59:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199994\/"},"modified":"2025-05-06T11:59:17","modified_gmt":"2025-05-06T03:59:17","slug":"%e7%a7%8d%e7%b1%bb%e5%8f%8a%e6%80%a7%e8%83%bd%e8%b0%83%e4%bc%98%e5%ae%9e%e8%b7%b5%ef%bc%9aoracle%e6%95%b0%e6%8d%ae%e5%ba%93%e7%b4%a2%e5%bc%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199994\/","title":{"rendered":"\u79cd\u7c7b\u53ca\u6027\u80fd\u8c03\u4f18\u5b9e\u8df5\uff1aOracle\u6570\u636e\u5e93\u7d22\u5f15"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u79cd\u7c7b\u53ca\u6027\u80fd\u8c03\u4f18\u5b9e\u8df5\uff1aOracle\u6570\u636e\u5e93\u7d22\u5f15<\/h1>\n<p>\u4eca\u65e5\u4e0d\u80af\u57cb\u5934\uff0c\u660e\u65e5\u4f55\u4ee5\u62ac\u5934\uff01\u6bcf\u65e5\u4e00\u53e5\u52aa\u529b\u81ea\u5df1\u7684\u8bdd\u54c8\u54c8~\u54c8\u55bd\uff0c\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7\uff0c\u4e3b\u8981\u5185\u5bb9\u662f\u8bb2\u89e3\u7b49\u7b49\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u6536\u85cf\u6216\u8005\u6709\u66f4\u597d\u7684\u5efa\u8bae\u5728\u8bc4\u8bba\u63d0\u51fa\uff0c\u6211\u90fd\u4f1a\u8ba4\u771f\u770b\u7684\uff01\u5927\u5bb6\u4e00\u8d77\u8fdb\u6b65\uff0c\u4e00\u8d77\u5b66\u4e60\uff01<\/p>\n<p>Oracle\u6570\u636e\u5e93\u7d22\u5f15\u7684\u79cd\u7c7b\u53ca\u6027\u80fd\u8c03\u4f18\u5b9e\u8df5<\/p>\n<p>\u5728\u6570\u636e\u5e93\u9886\u57df\u4e2d\uff0c\u7d22\u5f15\u662f\u4e00\u79cd\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u7684\u91cd\u8981\u5de5\u5177\u3002Oracle\u4f5c\u4e3a\u4e00\u6b3e\u5f3a\u5927\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u63d0\u4f9b\u4e86\u591a\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u7d22\u5f15\u4f9b\u7528\u6237\u9009\u62e9\uff0c\u5e76\u4e14\u8fd8\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u6027\u80fd\u8c03\u4f18\u7684\u65b9\u6cd5\uff0c\u4ee5\u4f18\u5316\u6570\u636e\u5e93\u7684\u6027\u80fd\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdOracle\u6570\u636e\u5e93\u4e2d\u5e38\u89c1\u7684\u7d22\u5f15\u79cd\u7c7b\uff0c\u5e76\u7ed3\u5408\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u4ecb\u7ecd\u5982\u4f55\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u3002<\/p>\n<p><strong>\u4e00\u3001Oracle\u6570\u636e\u5e93\u7d22\u5f15\u79cd\u7c7b<\/strong><\/p>\n<ol>\n<li>\n<p>\u666e\u901a\u7d22\u5f15\uff08B-Tree\u7d22\u5f15\uff09\uff1a\u666e\u901a\u7d22\u5f15\u662f\u6700\u5e38\u7528\u7684\u4e00\u79cd\u7d22\u5f15\u7c7b\u578b\uff0c\u5b83\u91c7\u7528B-Tree\uff08\u5e73\u8861\u6811\uff09\u7ed3\u6784\u5b58\u50a8\u7d22\u5f15\u4fe1\u606f\uff0c\u9002\u7528\u4e8e\u7b49\u503c\u67e5\u8be2\u548c\u8303\u56f4\u67e5\u8be2\u3002\u521b\u5efa\u666e\u901a\u7d22\u5f15\u7684SQL\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>CREATE INDEX idx_name ON table_name(column_name);<\/pre>\n<\/li>\n<li>\n<p>\u552f\u4e00\u7d22\u5f15\uff08Unique\u7d22\u5f15\uff09\uff1a\u552f\u4e00\u7d22\u5f15\u8981\u6c42\u7d22\u5f15\u5217\u7684\u503c\u552f\u4e00\uff0c\u5728\u63d2\u5165\u6216\u66f4\u65b0\u6570\u636e\u65f6\u4f1a\u8fdb\u884c\u552f\u4e00\u6027\u68c0\u67e5\u3002\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u7684SQL\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>CREATE UNIQUE INDEX idx_name ON table_name(column_name);<\/pre>\n<\/li>\n<li>\n<p>\u590d\u5408\u7d22\u5f15\uff08Composite\u7d22\u5f15\uff09\uff1a\u590d\u5408\u7d22\u5f15\u662f\u6307\u7d22\u5f15\u7531\u591a\u4e2a\u5217\u7ec4\u6210\uff0c\u9002\u7528\u4e8e\u591a\u5217\u7684\u67e5\u8be2\u6761\u4ef6\u3002\u521b\u5efa\u590d\u5408\u7d22\u5f15\u7684SQL\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>CREATE INDEX idx_name ON table_name(column_name1, column_name2);<\/pre>\n<\/li>\n<li>\n<p>\u4f4d\u56fe\u7d22\u5f15\uff08Bitmap\u7d22\u5f15\uff09\uff1a\u4f4d\u56fe\u7d22\u5f15\u9002\u7528\u4e8e\u6570\u636e\u5206\u5e03\u76f8\u5bf9\u5747\u5300\u7684\u5217\uff0c\u4f7f\u7528\u4f4d\u56fe\u6765\u8868\u793a\u7d22\u5f15\u4fe1\u606f\uff0c\u9002\u5408\u4e8e\u5927\u6570\u636e\u91cf\u4e0b\u7684\u9009\u62e9\u6027\u67e5\u8be2\u3002\u521b\u5efa\u4f4d\u56fe\u7d22\u5f15\u7684SQL\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>CREATE BITMAP INDEX idx_name ON table_name(column_name);<\/pre>\n<\/li>\n<li>\n<p>\u51fd\u6570\u7d22\u5f15\uff08Function-based\u7d22\u5f15\uff09\uff1a\u51fd\u6570\u7d22\u5f15\u662f\u5bf9\u7d22\u5f15\u5217\u7684\u51fd\u6570\u7ed3\u679c\u5efa\u7acb\u7d22\u5f15\uff0c\u53ef\u4ee5\u52a0\u901f\u5bf9\u51fd\u6570\u8ba1\u7b97\u540e\u7684\u7ed3\u679c\u8fdb\u884c\u67e5\u8be2\u3002\u521b\u5efa\u51fd\u6570\u7d22\u5f15\u7684SQL\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>CREATE INDEX idx_name ON table_name(func(column_name));<\/pre>\n<\/li>\n<\/ol>\n<p><strong>\u4e8c\u3001Oracle\u6570\u636e\u5e93\u6027\u80fd\u8c03\u4f18\u5b9e\u8df5<\/strong><\/p>\n<ol>\n<li>\u9009\u62e9\u5408\u9002\u7684\u7d22\u5f15\u7c7b\u578b\uff1a\u6839\u636e\u5177\u4f53\u7684\u4e1a\u52a1\u9700\u6c42\u548c\u67e5\u8be2\u6a21\u5f0f\uff0c\u9009\u62e9\u5408\u9002\u7684\u7d22\u5f15\u7c7b\u578b\uff0c\u907f\u514d\u521b\u5efa\u8fc7\u591a\u6216\u8fc7\u5c11\u7684\u7d22\u5f15\u3002<\/li>\n<li>\u4f18\u5316\u67e5\u8be2\u8bed\u53e5\uff1a\u7f16\u5199\u9ad8\u6548\u7684\u67e5\u8be2\u8bed\u53e5\u53ef\u4ee5\u51cf\u5c11\u6570\u636e\u5e93\u7684\u67e5\u8be2\u5f00\u9500\uff0c\u907f\u514d\u5168\u8868\u626b\u63cf\uff0c\u5c3d\u53ef\u80fd\u5229\u7528\u7d22\u5f15\u3002<\/li>\n<li>\n<p>\u7edf\u8ba1\u4fe1\u606f\u66f4\u65b0\uff1a\u5b9a\u671f\u66f4\u65b0\u8868\u7684\u7edf\u8ba1\u4fe1\u606f\u53ef\u4ee5\u5e2e\u52a9\u4f18\u5316\u67e5\u8be2\u6267\u884c\u8ba1\u5212\uff0c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u8fdb\u884c\u7edf\u8ba1\u4fe1\u606f\u66f4\u65b0\uff1a<\/p>\n<pre>EXEC DBMS_STATS.GATHER_TABLE_STATS('schema_name', 'table_name');<\/pre>\n<\/li>\n<li>\n<p>\u7d22\u5f15\u91cd\u5efa\u548c\u4f18\u5316\uff1a\u5b9a\u671f\u68c0\u67e5\u7d22\u5f15\u7684\u788e\u7247\u60c5\u51b5\uff0c\u6839\u636e\u9700\u8981\u8fdb\u884c\u7d22\u5f15\u91cd\u5efa\u6216\u4f18\u5316\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u8fdb\u884c\u7d22\u5f15\u91cd\u5efa\uff1a<\/p>\n<pre>ALTER INDEX idx_name REBUILD;<\/pre>\n<\/li>\n<li>\u4f18\u5316\u7f13\u51b2\u533a\u548cPGA\uff1a\u5408\u7406\u8bbe\u7f6e\u6570\u636e\u5e93\u7684\u7f13\u51b2\u533a\u548cPGA\u5927\u5c0f\uff0c\u53ef\u4ee5\u51cf\u5c11\u78c1\u76d8IO\u7684\u6b21\u6570\uff0c\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u3002<\/li>\n<\/ol>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0cOracle\u6570\u636e\u5e93\u7d22\u5f15\u7684\u79cd\u7c7b\u4e30\u5bcc\u591a\u6837\uff0c\u5408\u7406\u9009\u62e9\u9002\u5408\u7684\u7d22\u5f15\u7c7b\u578b\u53ef\u4ee5\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\uff1b\u540c\u65f6\uff0c\u901a\u8fc7\u5b9e\u8df5\u6027\u80fd\u8c03\u4f18\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u4f18\u5316\u6570\u636e\u5e93\u7684\u6027\u80fd\uff0c\u63d0\u5347\u7cfb\u7edf\u7684\u54cd\u5e94\u901f\u5ea6\u3002\u5e0c\u671b\u672c\u6587\u80fd\u4e3a\u8bfb\u8005\u63d0\u4f9b\u4e00\u4e9b\u6709\u7528\u7684\u53c2\u8003\u548c\u6307\u5bfc\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\u4e3b\u673a\u5b9d\u8d1d\uff01\u66f4\u591a\u5173\u4e8e\u6570\u636e\u5e93\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\u3002<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u79cd\u7c7b\u53ca\u6027\u80fd\u8c03\u4f18\u5b9e\u8df5\uff1aOracle&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-199994","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199994","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199994"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199994\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}