關于分區索引與全局索引性能比較的示例

說明:之前使用range分區做出來的效果不明顯,這次使用hash分區。

1、準備工作:

 ----創建兩張一樣的hash分區表,jacks_part和echos_part------------------
1
SQL> create table jacks_part (owner varchar2(30),object_id number,object_name varchar2(128)) 2 2 partition by hash(object_id) 3 3 partitions 30; 4 5 Table created. 6 7 SQL> create table echos_part (owner varchar2(30),object_id number,object_name varchar2(128)) 8 2 partition by hash(object_id) 9 3 partitions 30; 10 11 Table created. 12 ----分別向兩張表插入一些記錄-----------------
13
SQL> insert into jacks_part select owner,object_id,object_name from dba_objects; 14 15 72196 rows created. 16 17 SQL> insert into echos_part select owner,object_id,object_name from jacks_part; 18 19 72196 rows created. 20 21 SQL> commit; 22 23 Commit complete. 24 ----分別創建global索引和local索引---------------
25
SQL> create index globals_ind on jacks_part(object_id) 26 2 global partition by hash(object_id); 27 28 Index created. 29 30 SQL> create index locals_ind on echos_part(object_id) local; 31 32 Index created. 33 ----查詢索引是否正確--------------------------
34
SQL> select index_name,table_name,locality from user_part_indexes; 35 36 INDEX_NAME TABLE_NAME LOCALI 37 ------------------ ------------------------------ ------ 38 LOCALS_IND ECHOS_PART LOCAL 39 GLOBALS_IND JACKS_PART GLOBAL

?

2、分區索引性能優于全局索引的例子:

 1 SQL> set linesize 200;
 2 SQL> set autotrace traceonly;
 3 SQL> select /*+ index(echos_part,locals_ind) */ * from  echos_part where object_id>100;
 4 
 5 72097 rows selected.
 6 
 7 
 8 Execution Plan
 9 ----------------------------------------------------------
10 Plan hash value: 3092815211
11 
12 -----------------------------------------------------------------------------------------------------------------
13 | Id  | Operation               | Name    | Rows    | Bytes | Cost (%CPU)| Time    | Pstart| Pstop |
14 -----------------------------------------------------------------------------------------------------------------
15 |   0 | SELECT STATEMENT           |        |  4228 |   396K|    89   (0)| 00:00:02 |    |    |
16 |   1 |  PARTITION HASH ALL           |        |  4228 |   396K|    89   (0)| 00:00:02 |     1 |    30 |
17 |   2 |   TABLE ACCESS BY LOCAL INDEX ROWID| ECHOS_PART |  4228 |   396K|    89   (0)| 00:00:02 |     1 |    30 |
18 |*  3 |    INDEX RANGE SCAN           | LOCALS_IND |  4228 |    |    25   (0)| 00:00:01 |     1 |    30 |
19 -----------------------------------------------------------------------------------------------------------------
20 
21 Predicate Information (identified by operation id):
22 ---------------------------------------------------
23 
24    3 - access("OBJECT_ID">100)
25 
26 Note
27 -----
28    - dynamic sampling used for this statement (level=2)
29 
30 
31 Statistics
32 ----------------------------------------------------------
33       0    recursive calls
34       0    db block gets
35    10562   consistent gets
36       0    physical reads
37       0    redo size
38   3128267  bytes sent via SQL*Net to client
39    53285   bytes received via SQL*Net from client
40    4808    SQL*Net roundtrips to/from client
41       0    sorts (memory)
42       0    sorts (disk)
43    72097   rows processed
44 
45 SQL> select /*+ index(jacks_part,globals_ind) */ * from  jacks_part where object_id>100;
46 
47 72097 rows selected.
48 
49 
50 Execution Plan
51 ----------------------------------------------------------
52 Plan hash value: 2501448352
53 
54 -------------------------------------------------------------------------------------------------------------------
55 | Id  | Operation                | Name      | Rows  | Bytes | Cost (%CPU)| Time      | Pstart| Pstop |
56 -------------------------------------------------------------------------------------------------------------------
57 |   0 | SELECT STATEMENT            |          |  2500 |   234K|  4639   (1)| 00:00:56 |      |      |
58 |   1 |  PARTITION HASH SINGLE            |          |  2500 |   234K|  4639   (1)| 00:00:56 |    1 |    1 |
59 |   2 |   TABLE ACCESS BY GLOBAL INDEX ROWID| JACKS_PART  |  2500 |   234K|  4639   (1)| 00:00:56 | ROWID | ROWID |
60 |*  3 |    INDEX RANGE SCAN            | GLOBALS_IND |  2500 |      |    15   (0)| 00:00:01 |    1 |    1 |
61 -------------------------------------------------------------------------------------------------------------------
62 
63 Predicate Information (identified by operation id):
64 ---------------------------------------------------
65 
66    3 - access("OBJECT_ID">100)
67 
68 Note
69 -----
70    - dynamic sampling used for this statement (level=2)
71 
72 
73 Statistics
74 ----------------------------------------------------------
75       0    recursive calls
76       0    db block gets
77    74718   consistent gets
78       0    physical reads
79       0    redo size
80   3077218  bytes sent via SQL*Net to client
81    53285   bytes received via SQL*Net from client
82     4808   SQL*Net roundtrips to/from client
83       0    sorts (memory)
84       0    sorts (disk)
85    72097   rows processed

?

3、分區索引性能低于全局索引的例子1:

 1 SQL> select /*+ index(echos_part,locals_ind) */ count(*) from  echos_part where object_id>100;
 2 
 3 
 4 Execution Plan
 5 ----------------------------------------------------------
 6 Plan hash value: 2317569636
 7 
 8 --------------------------------------------------------------------------------------------------
 9 | Id  | Operation        | Name     | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
10 --------------------------------------------------------------------------------------------------
11 |   0 | SELECT STATEMENT    |         |     1 |    13 |    25   (0)| 00:00:01 |     |     |
12 |   1 |  SORT AGGREGATE     |         |     1 |    13 |          |      |     |     |
13 |   2 |   PARTITION HASH ALL|         |  4228 | 54964 |    25   (0)| 00:00:01 |     1 |    30 |
14 |*  3 |    INDEX RANGE SCAN | LOCALS_IND |  4228 | 54964 |    25   (0)| 00:00:01 |     1 |    30 |
15 --------------------------------------------------------------------------------------------------
16 
17 Predicate Information (identified by operation id):
18 ---------------------------------------------------
19 
20    3 - access("OBJECT_ID">100)
21 
22 Note
23 -----
24    - dynamic sampling used for this statement (level=2)
25 
26 
27 Statistics
28 ----------------------------------------------------------
29       0  recursive calls
30       0  db block gets
31     205  consistent gets
32       0  physical reads
33       0  redo size
34     424  bytes sent via SQL*Net to client
35     419  bytes received via SQL*Net from client
36       2  SQL*Net roundtrips to/from client
37       0  sorts (memory)
38       0  sorts (disk)
39       1  rows processed
40 
41 SQL> select /*+ index(jacks_part,globals_ind) */ count(*) from  jacks_part where object_id>100;
42 
43 
44 Execution Plan
45 ----------------------------------------------------------
46 Plan hash value: 2478129137
47 
48 ------------------------------------------------------------------------------------------------------
49 | Id  | Operation           | Name         | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
50 ------------------------------------------------------------------------------------------------------
51 |   0 | SELECT STATEMENT       |         |       1 |      13 |      15   (0)| 00:00:01 |         |         |
52 |   1 |  SORT AGGREGATE        |         |       1 |      13 |          |         |         |         |
53 |   2 |   PARTITION HASH SINGLE|         |    2500 | 32500 |      15   (0)| 00:00:01 |       1 |       1 |
54 |*  3 |    INDEX RANGE SCAN    | GLOBALS_IND |    2500 | 32500 |      15   (0)| 00:00:01 |       1 |       1 |
55 ------------------------------------------------------------------------------------------------------
56 
57 Predicate Information (identified by operation id):
58 ---------------------------------------------------
59 
60    3 - access("OBJECT_ID">100)
61 
62 Note
63 -----
64    - dynamic sampling used for this statement (level=2)
65 
66 
67 Statistics
68 ----------------------------------------------------------
69       0  recursive calls
70       0  db block gets
71     201  consistent gets
72       0  physical reads
73       0  redo size
74     424  bytes sent via SQL*Net to client
75     419  bytes received via SQL*Net from client
76       2  SQL*Net roundtrips to/from client
77       0  sorts (memory)
78       0  sorts (disk)
79       1  rows processed

?分區索引性能低于全局索引的例子2:

 1 SQL> drop index globals_ind;
 2 
 3 Index dropped.
 4 
 5 SQL> create index global_indexs on jacks_part(object_id) global;
 6 
 7 Index created.
 8 
 9 SQL> select /*+ index(echos_part,locals_ind) */ count(*) from  echos_part where object_id>100;
10 
11 
12 
13 Execution Plan
14 ----------------------------------------------------------
15 Plan hash value: 2317569636
16 
17 --------------------------------------------------------------------------------------------------
18 | Id  | Operation        | Name     | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
19 --------------------------------------------------------------------------------------------------
20 |   0 | SELECT STATEMENT    |         |     1 |     5 |   175   (0)| 00:00:03 |     |     |
21 |   1 |  SORT AGGREGATE     |         |     1 |     5 |          |      |     |     |
22 |   2 |   PARTITION HASH ALL|         | 72101 |   352K|   175   (0)| 00:00:03 |     1 |    30 |
23 |*  3 |    INDEX RANGE SCAN | LOCALS_IND | 72101 |   352K|   175   (0)| 00:00:03 |     1 |    30 |
24 --------------------------------------------------------------------------------------------------
25 
26 Predicate Information (identified by operation id):
27 ---------------------------------------------------
28 
29    3 - access("OBJECT_ID">100)
30 
31 
32 Statistics
33 ----------------------------------------------------------
34    1704  recursive calls
35       0  db block gets
36     437  consistent gets
37     206  physical reads
38       0  redo size
39 
40 SQL> select /*+ index(jacks_part,global_indexs) */ count(*) from  jacks_part where object_id>100;
41 
42 
43 Execution Plan
44 ----------------------------------------------------------
45 Plan hash value: 1016566238
46 
47 -----------------------------------------------------------------------------------
48 | Id  | Operation      | Name      | Rows  | Bytes | Cost (%CPU)| Time      |
49 -----------------------------------------------------------------------------------
50 |   0 | SELECT STATEMENT  |          |    1 |    5 |   201   (0)| 00:00:03 |
51 |   1 |  SORT AGGREGATE   |          |    1 |    5 |           |      |
52 |*  2 |   INDEX RANGE SCAN| GLOBAL_INDEXS | 72101 |   352K|   201   (0)| 00:00:03 |
53 -----------------------------------------------------------------------------------
54 
55 Predicate Information (identified by operation id):
56 ---------------------------------------------------
57 
58    2 - access("OBJECT_ID">100)
59 
60 
61 Statistics
62 ----------------------------------------------------------
63       1  recursive calls
64       0  db block gets
65     201  consistent gets
66     200  physical reads
67       0  redo size

?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/276398.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/276398.shtml
英文地址,請注明出處:http://en.pswp.cn/news/276398.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Vue Router 4.0 正式發布!煥然一新。

關注若川視野,回復"pdf" 領取資料,回復"加群",可加群長期交流學習12月8日,Vue Router 4 正式發布穩定版本。在經歷了 14 個 Alpha,13 個 Beta 和 6 個 RC 版本之后,Vue Router v4 閃亮…

實戰Nginx與PHP(FastCGI)的安裝、配置與優化

轉載鏈接:http://ixdba.blog.51cto.com/2895551/806622 一、什么是 FastCGI FastCGI是一個可伸縮地、高速地在HTTP server和動態腳本語言間通信的接口。多數流行的HTTP server都支持FastCGI,包括Apache、Nginx和lighttpd等,同時,…

python在運維自動化的前景_現在學運維自動化python和大數據?

{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],"search_count":[{"count_phone":7,"count":7}]},"card":[{"des":"阿里云實時計算(Alibaba Cloud Realtime Com…

BOM算最尾階的損耗率 成品直接到料件

假設由B生產為A經過3道工序,各工序的損耗率分別為 C1,C2,C3; 由D生產為B經過1道工序,作業損耗率為C4. 請問在BOM中建立材料的損耗率應該是怎樣的呀? 我的理解是這樣:A的產出B的投入(1-C1)(1-C2)(1-C3)所以B的投入A的產出/(1-C1)(1-C2)(1-C3)所以建A的BOM時,材料B的損耗率為: …

10個前端8個用Vue的,怎么才能在面試中出彩?

大家好,我是若川。現在但凡出去面試,面試官幾乎必問 Vue3.0 。不僅會問一些核心特性,還會問原理層面的問題。比如:?框架層面問題:Vue3.0 新特性 Composition API 與 React.js 中 Hooks 的異同點??源碼、原…

ASP.NET MVC學習之(5):Html.ActionLink

本文整理了該方法的幾種重載形式: 一 Html.ActionLink("linkText","actionName") 該重載的第一個參數是該鏈接要顯示的文字,第二個參數是對應的控制器的方法,默認控制器為當前頁面的控制器,如果當前頁面的控制…

python qq模塊_常用的Python模塊

目錄1、使用copy模塊來復制>>> class Animal:def _init_(self, species, number_of_legs, color):self.species speciesself.number_of_legs number_of_legsself.color color>>> harry Animal()>>> harry._init_(hippogriff, 6, pink)>>&…

故鄉 | 登高望遠,夜幕降臨

歡迎星標我的公眾號若川視野,回復加群,長期交流學習上周末看了幾集豆瓣評分8.5分劉同同名小說的青春劇《我在未來等你》,讓我回想起自己的高中生活。也想起小時候經常爬到故鄉附近的小山,看夕陽西下。時常和同事開玩笑說&#xff…

CentOS5安裝Nginx1.4+PHP5.5 FastCGI

轉載鏈接:http://blog.csdn.net/staricqxyz/article/details/17012329 yum -y install gcc gcc-c autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2…

FTP服務器的搭建

IIS IIS所提供的FTP功能比較簡單: 用戶依賴于“操作系統用戶”;只提供了全局讀(瀏覽和復制)、寫(刪除、修改、添加)功能設置,也就是說所有的讀寫權限都相同;“用戶”與“對應目錄”的…

一份熱乎乎的滴滴前端面經

關注若川視野,回復"pdf" 領取資料,回復"加群",可加群長期交流學習滴滴前端實習面經滴滴是我投簡歷之后第二家面試的公司, 國慶節前兩三天投的簡歷, 國慶后復工第一天就給我打了電話約一面。那時候…

用webBrowser取源文件取不到的點擊數--選秀榜selectop.com網站內容管理系統之六

用idhttp可以取到源文件,但網站用腳本代碼,源文件是看不到,并且代碼的結果也取不出。webBrowser可以多次返回下載到的內容,不包括任何html語法,這個當中就有文章的點擊數。在WebBrowser1DownloadComplete事件中處理&am…

Nginx負載均衡配置

轉載鏈接:http://blog.csdn.net/staricqxyz/article/details/16984029 將域名指向Nginx服務器 訪問www.test.com會轉發到192.168.1.22,192.168.1.23 user nobody nobody; worker_processes 1; events { worker_connections 1024; } http { …

linux查看python環境變量_Linux中添加PYTHONPATH配置anaconda環境變量方法

因為最近開發多智能體模型需要把自己寫的環境打包import,環境是統一的,如果不加入環境變量,每次測一個算法都要把包作為附屬腳本和算法腳本放一起非常麻煩。所以就想把這些寫的環境加入到python的環境變量里,這樣就不用每次測試都…

yii_wiki_145_yii-cjuidialog-for-create-new-model (通過CJuiDialog來創建新的Model)

/**** CJuiDialog for create new model http://www.yiiframework.com/wiki/145/cjuidialog-for-create-new-model/translated by php攻城師http://blog.csdn.net/phpgcsIntroduction Scenario Preparation of the form Enhance the action create The dialog Summary ***/Intr…

真誠推薦幾個最值得關注的前端公眾號

前端技術日新月異,發展迅速,作為一個與時俱進的前端工程師,需要不斷的學習。這里強烈推薦幾個前端開發工程師必備的優質公眾號,希望對你有所幫助。大家可以像我一樣,利用碎片時間閱讀這些公眾號的文章。code秘密花園一…

Silverlight Unit Test Framework

微軟在08年的時候推出了一個Silverlight的單元測試框架,該框架在Mix 08的時候與Silverlight controls同時推出的,微軟工程師Jeff Wilcox一直參與維護該單元測試框架。Scott Gu對這個框架的介紹Jeff Wilcox提供的視頻介紹該框架的源代碼已經包括在Silverl…

Nginx 反向代理、負載均衡、頁面緩存、URL重寫及讀寫分離詳解

轉載鏈接:http://freeloda.blog.51cto.com/2033581/1288553 大綱 一、前言 二、環境準備 三、安裝與配置Nginx 四、Nginx之反向代理 五、Nginx之負載均衡 六、Nginx之頁面緩存 七、Nginx之URL重寫 八、Nginx之讀寫分離 注,操作系統為 CentOS 6.4 x86_64…

[Jobdu] 題目1499:項目安排

題目描述:小明每天都在開源社區上做項目,假設每天他都有很多項目可以選,其中每個項目都有一個開始時間和截止時間,假設做完每個項目后,拿到報酬都是不同的。由于小明馬上就要碩士畢業了,面臨著買房、買車、…

How to: Display a Gradient Fill

To display a gradient fill 第一步:In Visual Studio, create a Smart Device project. 第二部:Add the Gradientfill and GradientFilledButton classes to your project. public sealed class GradientFill{ // This method wraps the …