RE: Lookup/Code table as hot block

  • From: <JayMiller@xxxxxxxxxxxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 2 May 2006 14:12:18 -0400

Remember that you have to be sure that the table will never have rows in
excess of the number of hashkeys if you choose this option.



Jay Miller

Sr. Oracle DBA



-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
Sent: Tuesday, May 02, 2006 5:37 AM
To: sjaffarhussain@xxxxxxxxx
Cc: oracle-l@xxxxxxxxxxxxx
Subject: Re: Lookup/Code table as hot block


You could try to put the table into a single table hash cluster, and
specify pctfree and pctused according to what jared suggested. Using a
cluster has the additional benefit of reducing ios, as compared to an
index + table lookup which in turn reduces latches and contention
(getting one or more index blocks - root -> branch -> leaf, plus
eventually one table access by rowid , versus a direct key to rowid
conversion access going directly to the table). 

test@CENTRAL> create cluster c1 (key int) single table hashkeys 100
pctfree 99 pctused 1;

Cluster created.

test@CENTRAL> create table t1 (key int, data1 varchar2(20), data2
varchar2(20)) cluster c1 (key); 

Table created.

test@CENTRAL> insert into t1 values (1,'a','a');

1 row created.

test@CENTRAL> insert into t1 values (2,'b','b');

1 row created.

test@CENTRAL > insert into t1 values (3,'c','c');

1 row created.

test@CENTRAL> commit;

Commit complete.

test@CENTRAL> select dbms_rowid.rowid_block_number(rowid) from t1


test@CENTRAL> exec dbms_stats.gather_table_stats(user,'T1'); 

PL/SQL procedure successfully completed.

test@CENTRAL> set autotrace on stat exp  

test@CENTRAL> select * from t1 where key = 3;

       KEY DATA1                DATA2
---------- -------------------- -------------------- 
         3 c                    c

Execution Plan
Plan hash value: 3152376638

| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)|
|   0 | SELECT STATEMENT  |      |     1 |     7 |     0   (0)|
|*  1 |  TABLE ACCESS HASH| T1   |     1 |     7 |            | 

Predicate Information (identified by operation id):

   1 - access("KEY"=3) 

          1  recursive calls
          0  db block gets
          3  consistent gets
          0  physical reads
          0  redo size 
        520  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed 


That should scale really well too.


This message is confidential and sent by TD Waterhouse solely for
use by the intended recipient. If you are not the intended
recipient, you are hereby notified that any use, distribution or
copying of this communication is strictly prohibited. This should
not be deemed as an offer or solicitation, to buy or sell any
product. Any 3rd party information contained herein was prepared by
sources deemed reliable, but is not guaranteed. TD Waterhouse does
not accept electronic instructions that would require an original
signature. Information received by or sent from TD Waterhouse is
stored, subject to review, and may be produced to regulatory
authorities or others with a legal right to such.

Other related posts: