Page 1 of 1

Searching a hash File

Posted: Thu Aug 11, 2005 9:42 am
by als110
Does anyone know a way to search for a row in a hash file either with a unix command or in Administrator. Basically I want to grep for a row but im not sure how to do this with a hash file.

Thanks

Aaron

Posted: Thu Aug 11, 2005 10:04 am
by chesterkchu
Hi Aaron,

Try "LIST filename WITH @ID=key".

Thanks,

Chester

Posted: Thu Aug 11, 2005 10:10 am
by als110
This only will search if you know the id of the record. I want to know if there is a way to search for a given part of the actual record.

Posted: Thu Aug 11, 2005 10:40 am
by chulett
Why not 'View Data' and then use the Find option there?

Posted: Thu Aug 11, 2005 10:41 am
by chesterkchu
Hi Aaron,

Try LIST filename WITH columnname = 'value'

:lol:

Thanks,

Chester

Posted: Thu Aug 11, 2005 10:43 am
by als110
chulett wrote:Why not 'View Data' and then use the Find option there?
Craig there are over 102 million rows in my hash file this option is not feasible.

Thanks

Posted: Thu Aug 11, 2005 10:45 am
by als110
chesterkchu wrote:Hi Aaron,

Try LIST filename WITH columnname = 'value'

:lol:

Thanks,

Chester
That works but I'm not sure how well it will work with 102 million rows. I tried is on a smaller has file of 2 million and it take about 5 min to return.

Thanks

Posted: Thu Aug 11, 2005 10:47 am
by jmessiha
als110 wrote:
chulett wrote:Why not 'View Data' and then use the Find option there?
Craig there are over 102 million rows in my hash file this option is not feasible.

Thanks
Yes, you'd have to skip every time your search failed, viewing 9999 rows at a time. Sounds like too much fun. If your record was at the very bottom, you wouldn't find it until after you skipped 10202 times.

Joey

Posted: Thu Aug 11, 2005 10:48 am
by chesterkchu
jmessiha wrote:
als110 wrote:
chulett wrote:Why not 'View Data' and then use the Find option there?
Craig there are over 102 million rows in my hash file this option is not feasible.

Thanks
Yes, you'd have to skip every time your search failed, viewing 9999 rows at a time. Sounds like too much fun. If your record was at the very bottom, you wouldn't find it until after you skipped 10202 times.

Joey
Therefore, my solution would be more efficient. You can run it and go eat lunch and come back to your record!

Thanks,

Chester

Posted: Thu Aug 11, 2005 10:49 am
by jmessiha
als110 wrote:
chesterkchu wrote:Hi Aaron,

Try LIST filename WITH columnname = 'value'

:lol:

Thanks,

Chester
That works but I'm not sure how well it will work with 102 million rows. I tried is on a smaller has file of 2 million and it take about 5 min to return.

Thanks
Chester's way seems like the only way, and will perform at O(n) worst-case efficiency since you are searching for the primary key and not the natural key. I don't think there is a better way, so you'll have to wait for the search to come back.

Posted: Thu Aug 11, 2005 10:53 am
by ArndW
I you need to do this search repeatedly, you can do a "CREATE.INDEX {TableName} {ColumnName}" and subsequent commands LIST commands on that column will automatically use the index. The CREATE.INDEX command will take a bit of time to create, though.

Posted: Fri Aug 12, 2005 12:50 am
by ray.wurlod
If you are searching for the primary key, the row will be returned instantly irrespective of its location.
Why?
The key value is processed by a hashing algorithm that returns the address of the page on which the key and its record are stored. One I/O operation is required to retrieve that page.

If you are searching based on any other criterion the hashed file behaves like any other database table (which ultimately is what it is). As Arnd suggested, your search can be speeded if the field(s) required in your search criteria are indexed.

Finally, there is no utility for doing this from the operating system prompt; you must be executing a query in the database environment. Get to this from the operating system prompt using the dssh or uv command. Either can take your query (surrounded by double quotes) as a command line argument.