http://www.perlmonks.org?node_id=111223


in reply to flat-file vs DB_File

DB_File is faster.

There is often a tradeoff in dynamically allocated data structures between how little memory you use, and how fast your data access and manipulation can be. DB_File has unused memory sections. But that doesn't matter for access because you don't sequentially scan through the file, you jump right to the data, and it is a good thing for writing because if you want to add a little bit to one record, you don't have to rewrite the whole file to get the space.

Replies are listed 'Best First'.
Re: Re (tilly) 1: flat-file vs DB_File
by dws (Chancellor) on Sep 09, 2001 at 04:39 UTC
    But that doesn't matter for access because you don't sequentially scan through the file, you jump right to the data, ...

    If the file page you're jumping to is already in the kernel's disk cache, this is a win. But if getting to the target page requires moving the disk head, you might be better off with a sequential scan. For an infrequently accessed file in the 7-8 disk page range, I suspect that the linear scan might win.

    I think we're in the toss-up category.

    BTW, this is a tricky one to test by profiling, since you may have to go out of your way to make sure that the file isn't cached.

Re: Re (tilly) 1: flat-file vs DB_File
by Anonymous Monk on Sep 09, 2001 at 04:39 UTC
    Thank you.