Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to hash a set of columns ?
Well, that's the thing with hashing. Uniqueness is never gauaranteed,
yes? Not only that, the algorithm within dbms_utility.get_hash_value,
which ORACLE does not publish, can change from release to release. If
you want a hashing function that will always return the same value for
a particular string, write your own.
It is all a matter of probability. If you increase the hash bucket size, the chance of collisions will be lower. If you want to hash 100 values with 50 as hash size, there is no way you can avoid collisions. The max hash size you can use with dbms_utility.get_hash_value is (2**30 - 1) - plenty of room for you lower the collision probability to a level that is statistically insignificant.
"Anurag Varma" <avdbi_at_hotmail.com> wrote in message news:<YWkua.5456$2c4.2458_at_news02.roc.ny.frontiernet.net>... > "Jusung Yang" <JusungYang_at_yahoo.com> wrote in message news:130ba93a.0305071328.31c0a95b_at_posting.google.com...
> > To OP: > Be aware however that dbms_utility.get_hash_value might return same/duplicate hash value for two different strings. > In Jusung's case for example: > SQL>select dbms_utility.get_hash_value('KU$_CONSTRAINT_COL_LIST_T',100,800) hashval > 2 from dual; > > HASHVAL > ---------- > 899 > > SQL>select dbms_utility.get_hash_value('GV$TRANSACTION_ENQUEUE',100,800) hashval > 2 from dual; > > HASHVAL > ---------- > 899 > > ... try this query yourself .. > 1 select oname, dbms_utility.get_hash_value(oname,100,800) hashval > 2 from (select distinct object_name oname from dba_objects) > 3* order by hashval > > ... of course if you change the ranges, the above might not clash > SQL>select dbms_utility.get_hash_value('GV$TRANSACTION_ENQUEUE',100,8000) hashval from dual; > > HASHVAL > ---------- > 5699 > > SQL>select dbms_utility.get_hash_value('KU$_CONSTRAINT_COL_LIST_T',100,8000) hashval from dual; > > HASHVAL > ---------- > 4099 > .. however, original point being: The values are not guaranteed to be unique. Just be aware of it and take appropriate precautions. > > AnuragReceived on Thu May 08 2003 - 16:17:10 CDT
![]() |
![]() |