next Backend / Frontend
up High-Performance-Tuning
previous StatsPack
  Contents   Index

Subsections


Cluster und Index-Organized Tables

Verteilung von Zeilen in einer Tabelle

Table      Cluster     Index-organized Table

---------- Ordering of Rows --------->

Random     Grouped     Ordered

Clusters

Unclustered ORD und ITEM Tabellen

ORD_NO	PROD	QTY	...
-----	------	------
101	A4102	20
102	A2091	11
102	G7830 	20
102	N9587 	26
101	A5675	19
101	W0824	10
ORD_NO	ORD_DT	  CUST_CD
------	------	   ------
101	05-JAN-97	   R01
102	07-JAN-97	   N45


Clustered ORD und ITEM Tabellen

Cluster Key
(ORD_NO)
101    ORD_DT       CUST_CD
        05-JAN-97    R01 	
             PROD    QTY
             A4102   20
             A5675   19 	
             W0824   10
102  	 ORD_DT       CUST_CD
       07-JAN-97     N45
             PROD    QTY
             A2091   11
             G7830   20 	
             N9587   26


Cluster Arten


Index Cluster


Hash Cluster

Erstellen eines Index Clusters

1. Cluster erstellen.
CREATE CLUSTER scott.ord_clu (ord_no NUMBER(3)) 
   SIZE 200 TABLESPACE DATA01 
   STORAGE(INITIAL 5M NEXT 5M PCTINCREASE 0)
;
2. Cluster-Index erstellen.
CREATE INDEX scott.ord_clu_idx 
  ON CLUSTER scott.ord_clu 
  TABLESPACE INDX01 
  STORAGE(INITIAL 1M NEXT 1M PCTINCREASE 0)
;
3. Tabellen im Cluster erstellen.
CREATE TABLE scott.ord 
  (
   ord_no NUMBER(3) 
   CONSTRAINT ord_pk PRIMARY KEY, 
   ord_dt DATE, cust_cd VARCHAR2(3)
   ) 
  CLUSTER scott.ord_clu(ord_no)
;
CREATE TABLE scott.item
  (
    ord_no NUMBER(3) 
    CONSTRAINT item_ord_fk REFERENCES scott.ord, 
    prod VARCHAR2(5), 
    qty NUMBER(3), 
    CONSTRAINT item_pk PRIMARY KEY(ord_no,prod)
   ) 
  CLUSTER scott.ord_clu(ord_no)
;

Erstellen eines Hash Clusters

1. Cluster erstellen.
CREATE CLUSTER scott.off_clu 
  (
   country VARCHAR2(2),postcode VARCHAR2(8)
   ) 
  SIZE 500 HASHKEYS 1000
  TABLESPACE DATA01 
  STORAGE(INITIAL 5M NEXT 5M PCTINCREASE 0);
2. Tabellen im Cluster erstellen.
CREATE TABLE scott.office
  (
   office_cd NUMBER(3), 
   cost_ctr NUMBER(3), 
   country VARCHAR2(2), 
   postcode VARCHAR2(8)
   ) 
  CLUSTER scott.off_clu(country,postcode)
;


Dropping Clusters

Nutze INCLUDING TABLES für das Löschen der Tabellen und des Clusters.
DROP CLUSTER scott.ord_clu INCLUDING TABLES;
Oder lösche die Tabellen vor dem Cluster.
DROP TABLE scott.ord;
DROP TABLE scott.item;
DROP CLUSTER scott.ord_clu;


Index-Organized Tables

Indexed access on table:
ROWID

Accessing index-organized table:
Non-key columns
Key column
Row header

Creating Index-Organized Tables

CREATE TABLE scott.sales
  (
   office_cd  NUMBER(3),
   qtr_end    DATE,
   revenue    NUMBER(10,2),
   review     VARCHAR2(1000),
   CONSTRAINT sales_pk 
   PRIMARY KEY(office_code, qtr_end)
  )
  ORGANIZATION INDEX TABLESPACE data01
  PCTTHRESHOLD 20
  OVERFLOW TABLESPACE data02
;


Row Overflow

IOT tablespace
Overflow tablespace

Übung Index-Cluster

Übungen siehe Seite [*].
next Backend / Frontend
up High-Performance-Tuning
previous StatsPack
  Contents   Index


Stefan Hietel dama.go GmbH, Robert Warnke http://rowa.giso.de