真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

索引系列五--索引特性之存列值優(yōu)化sumavg

SUM/AVG的優(yōu)化

成都創(chuàng)新互聯(lián)是專業(yè)的政和網(wǎng)站建設(shè)公司,政和接單;提供成都網(wǎng)站設(shè)計、成都做網(wǎng)站,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行政和網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

drop table t purge;

create table t as select * from dba_objects;

create index idx1_object_id on t(object_id);

set autotrace on

set linesize 1000

set timing on 

select sum(object_id) from t; 

執(zhí)行計劃

----------------------------------------------------------------------------------------

| Id  | Operation             | Name           | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT      |                |     1 |    13 |    49   (0)| 00:00:01 |

|   1 |  SORT AGGREGATE       |                |     1 |    13 |            |          |

|   2 |   INDEX FAST FULL SCAN| IDX1_OBJECT_ID | 92407 |  1173K|    49   (0)| 00:00:01 |

----------------------------------------------------------------------------------------

統(tǒng)計信息

----------------------------------------------------------

          0  recursive calls

          0  db block gets

        170  consistent gets

          0  physical reads

          0  redo size

        432  bytes sent via SQL*Net to client

        415  bytes received via SQL*Net from client

          2  SQL*Net roundtrips to/from client

          0  sorts (memory)

          0  sorts (disk)

          1  rows processed

          

--比較一下假如不走索引的代價,體會一下這個索引的重要性

select /*+full(t)*/ sum(object_id) from t;  

SUM(OBJECT_ID)

--------------

  2732093100         

執(zhí)行計劃

---------------------------------------------------------------------------

| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |

---------------------------------------------------------------------------

|   0 | SELECT STATEMENT   |      |     1 |    13 |   292   (1)| 00:00:04 |

|   1 |  SORT AGGREGATE    |      |     1 |    13 |            |          |

|   2 |   TABLE ACCESS FULL| T    | 92407 |  1173K|   292   (1)| 00:00:04 |

---------------------------------------------------------------------------

統(tǒng)計信息

----------------------------------------------------------

          0  recursive calls

          0  db block gets

       1047  consistent gets

          0  physical reads

          0  redo size

        432  bytes sent via SQL*Net to client

        415  bytes received via SQL*Net from client

          2  SQL*Net roundtrips to/from client

          0  sorts (memory)

          0  sorts (disk)

          1  rows processed     

          

--起來類似的比如AVG,和SUM是一樣的,如下:

select avg(object_id) from t; 

AVG(OBJECT_ID)

--------------

  37365.5338

執(zhí)行計劃

----------------------------------------------------------------------------------------

| Id  | Operation             | Name           | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT      |                |     1 |    13 |    49   (0)| 00:00:01 |

|   1 |  SORT AGGREGATE       |                |     1 |    13 |            |          |

|   2 |   INDEX FAST FULL SCAN| IDX1_OBJECT_ID | 92407 |  1173K|    49   (0)| 00:00:01 |

----------------------------------------------------------------------------------------

統(tǒng)計信息

----------------------------------------------------------

          0  recursive calls

          0  db block gets

        170  consistent gets

          0  physical reads

          0  redo size

        448  bytes sent via SQL*Net to client

        415  bytes received via SQL*Net from client

          2  SQL*Net roundtrips to/from client

          0  sorts (memory)

          0  sorts (disk)

          1  rows processed

--不知大家注意到?jīng)],這里的試驗已經(jīng)告訴我們了,OBJECT_ID列是否為空,也不影響SUM/AVG等聚合的結(jié)果。          


標(biāo)題名稱:索引系列五--索引特性之存列值優(yōu)化sumavg
網(wǎng)站路徑:http://weahome.cn/article/jiegdp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部