hi all,
Usually when we write data into Hashed file, then the records will be in shuffled manner. Why is it so? Any reason behind that?
Thanks in advance...
veera...
Hashed file
Moderators: chulett, rschirm, roy
That is a function of many databases. With hashed files the key is "hashed" into a number which corresponds to a hashed file group (or bucket). When the file is read in unsorted order it will read keys from each group and this will give you the "shuffled" order you see.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
It is axiomatic that you ought to have no control over physical storage of any individual record; this is a function of the database server so that it can retrieve that record efficiently. Hashed files implement database tables in a number of database products, including UniVerse and UniData, and use a hashing algorithm to determine the physical storage location.
In all cases if you need ordered data retrieved, you specify that in the query.
In all cases if you need ordered data retrieved, you specify that in the query.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
veera24 - in order to see Ray's post in its entirety, consider signing up for a membership
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
Re: Hashed file
That's what hashing is - it generates a number based on the input key, often by adding up all the ASCII characters with weighting and modulus functions applied, and uses the resulting number to decide where to put or look for the result. If you stream the contents out, you get them in numerical order of the hash key, which may well appear random. The better the hashing algorithm, the more random the positions are, as this produces fewer "collisions" where two records produce the same hashed value and it then has to store them in a list which it then has to traverse linearly (usually, could be a btree though) to find the right one.veera24 wrote:Usually when we write data into Hashed file, then the records will be in shuffled manner. Why is it so?
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant