[NTLUG:Discuss] db vs flat file
Greg Edwards
greg at nas-inet.com
Sat Dec 15 11:11:03 CST 2001
David Camm wrote:
>
> i'm about to write some code to do a search based on condtions among
> several fields in records in a file.
>
> i can use either a flat file or a hash version of the file.
>
> as the file gets larger (multiple thousands of records) will it be
> faster to:
>
> open(I, 'inputfile'); while (<I>) { .......} close (I);
>
> or:
>
> tie (%D .... input.db...) while (($k,$v) = each %D){ .....} untie %D;
>
> my ***GUESS*** is that dbm support contains more code than sequential
> file support and hence might be slower, but that's just a guess.
>
> any opinions (or hard facts) would be greatly appreciated.
>
> david camm
> advanced web systems
>
David,
Just some food for thought:) Disconnect your index (lookup) processing
from the actual data using an index file. Build your hash table (or
sorted reference list) and store it in the index file. Use the index
file as your search file and pull the actual data only when needed.
This is only worth the effort if your data set (per record) is larger
than just the key field your searching on.
--
Greg Edwards
New Age Software, Inc.
http://www.nas-inet.com
More information about the Discuss
mailing list