[NTLUG:Discuss] db vs flat file

Bug Hunter bughuntr at one.ctelcom.net
Fri Dec 14 15:36:31 CST 2001


  hmm.  db files typically have keys that allow you to go to the specific
record if you know the key.

  Otherwise, flat files would be faster for a sequential search, to some
extent.

  The next best thing might be a compromise where the first two letters
(or so) of each of the stored fields is the key.  Then, you get only a few
records to search for for any situation.

  the very best thing is to use something like MySQL, which has interfaces
to things like PHP, which is what your code looks like. You can then do

  SELECT * FROM TABLENAME WHERE FIELD1='BLAH' AND FIELD2 = 'BLA2' AND
FIELD3 = 'BLA4';



On Fri, 14 Dec 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
> 
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
> 





More information about the Discuss mailing list