A performance test case of single table hash cluster.
This is the secondary test of single table hash cluster, I want to verify the efficiency of the way I used to define the SIZE and HASHKEYS option. And I also want to verify the efficiency of hash function provided by Oracle for whether it can provide evenly distributed key. I choose 10M rows from a big table, the unloaded text file size is about 1.2G. In this case, I will set the HASHKEYS * SIZE to about 2GB. The SQL used to create the cluster is :
CREATE CLUSTER C_USER_HOST_ID_LOOKUP (USER_ID NUMBER(38,0))
SIZE 8192 SINGLE TABLE HASHKEYS 262144;
Then I use sqlldr to load these 10M rows, because you cannot use direct load mode for cluster table, so it goes a little slowly, it take me about 2 hours to finish the data loading. Then run the following PL/SQL code to verify the performance of the HASH access method.
DECLARE
TEMP VARCHAR2(64);
BEGIN
FOR REC IN (SELECT USER_ID FROM CR_FLOUTEST) LOOP
SELECT /* FLOU_TEST */ userid INTO TEMP FROM CR_FLOUTEST
WHERE USER_ID = REC.USER_ID;
END LOOP;
END;
/
After the PL/SQL finished, find out the hash value of the select statement, and query some data from V$SQL performance view. It's seems the SIZE and HASHKEYS is setting correctly, and also Oracle provide a very effective built-in hash function for us.
SQL> SELECT HASH_VALUE, BUFFER_GETS, EXECUTIONS
2 FROM V$SQL WHERE HASH_VALUE=2716314996;
HASH_VALUE BUFFER_GETS EXECUTIONS
---------- ----------- ----------
2716314996 9998912 9998777
Due to the low speed of the data load, I cannot make the decision to convert a table with 200M rows to single hash cluster table. Hope Oracle can add hash based index in later version.
