WEB开发网
开发学院数据库Oracle 创建与维护Oracle分区表和本地索引 阅读

创建与维护Oracle分区表和本地索引

 2008-08-26 12:44:08 来源:WEB开发网   
核心提示: SQL>COLsegment_namefora20SQL>COLPARTITION_NAMEfora20SQL>SELECTsegment_name,partition_name,tablespace_name2FROMdba_segments3WHEREsegment_

 SQL>COLsegment_namefora20
  SQL>COLPARTITION_NAMEfora20
  SQL>SELECTsegment_name,partition_name,tablespace_name
  2FROMdba_segments
  3WHEREsegment_name='DBOBJS_IDX';
  SEGMENT_NAMEPARTITION_NAMETABLESPACE_NAME
  ----------------------------------------------------------------------
  DBOBJS_IDXDBOBJS_06USERS
  DBOBJS_IDXDBOBJS_07USERS
  SQL>insertintodbobjs
  2selectobject_id,object_name,created
  3fromdba_objectswherecreated
  6227rowscreated.
  SQL>commit;
  Commitcomplete.
  SQL>selectcount(*)fromdbobjspartition(DBOBJS_06);
  COUNT(*)
  ----------
  6154
  SQL>selectcount(*)fromdbobjspartition(dbobjs_07);
  COUNT(*)
  ----------
  73

我们可以通过查询来对比一下分区表和非分区表的查询性能差异:

SQL>setautotraceon
  SQL>selectcount(*)fromdbobjswherecreated<to_date('01/01/2008','dd/mm/yyyy');
  COUNT(*)
  ----------
  6227
  ExecutionPlan
  ----------------------------------------------------------
  0SELECTSTATEMENTptimizer=CHOOSE(Cost=1Card=1Bytes=9)
  10SORT(AGGREGATE)
  21PARTITIONRANGE(ALL)
  32INDEX(RANGESCAN)OF'DBOBJS_IDX'(NON-UNIQUE)(Cost=2Card=8Bytes=72)
  Statistics
  ----------------------------------------------------------
  0recursivecalls
  0dbblockgets
  25consistentgets
  0physicalreads
  0redosize
  380bytessentviaSQL*Nettoclient
  503bytesreceivedviaSQL*Netfromclient
  2SQL*Netroundtripsto/fromclient
  0sorts(memory)
  0sorts(disk)
  1rowsprocessed
  SQL>selectcount(*)fromdbobjswherecreated<to_date('01/01/2007','dd/mm/yyyy');
  COUNT(*)
  ----------
  6154
  ExecutionPlan
  ----------------------------------------------------------
  0SELECTSTATEMENTptimizer=CHOOSE(Cost=1Card=1Bytes=9)
  10SORT(AGGREGATE)
  21INDEX(RANGESCAN)OF'DBOBJS_IDX'(NON-UNIQUE)(Cost=2Card=4Bytes=36)
  Statistics
  ----------------------------------------------------------
  0recursivecalls
  0dbblockgets
  24consistentgets
  0physicalreads
  0redosize
  380bytessentviaSQL*Nettoclient
  503bytesreceivedviaSQL*Netfromclient
  2SQL*Netroundtripsto/fromclient
  0sorts(memory)
  0sorts(disk)
  1rowsprocessed
  SQL>selectcount(distinct(object_name))fromdbobjswherecreated<to_date('01/01/2007','dd/mm/yyyy');
  COUNT(DISTINCT(OBJECT_NAME))
  ----------------------------
  4753
  ExecutionPlan
  ----------------------------------------------------------
  0SELECTSTATEMENTptimizer=CHOOSE(Cost=1Card=1Bytes=75)
  10SORT(GROUPBY)
  21TABLEACCESS(BYLOCALINDEXROWID)OF'DBOBJS'(Cost=1Card=4Bytes=300)
  32INDEX(RANGESCAN)OF'DBOBJS_IDX'(NON-UNIQUE)(Cost=2Card=1)
  Statistics
  ----------------------------------------------------------
  0recursivecalls
  0dbblockgets
  101consistentgets
  0physicalreads
  0redosize
  400bytessentviaSQL*Nettoclient
  503bytesreceivedviaSQL*Netfromclient
  2SQL*Netroundtripsto/fromclient
  1sorts(memory)
  0sorts(disk)
  1rowsprocessed

对于非分区表的测试:

Tags:创建 维护 Oracle

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接