Although I have been using perl for a number of years now I haven't used any database packages. After reading about persistent data in "Mastering Perl" I decide to use DBM::Deep and compare it with Storable. In the following code my hash has about 350 elements each being a reference to an anonymous array of 13 values (file stats, extension, etc). I would estimate that there is 150-200 bytes of data per hash element. I sort the hash (to make the $db->import faster) and then time both a save by DBM::Deep and by Storable.

my $db=DBM::Deep->new(file=>"c:/testpad/collector.Deep",autoflush=>0); my %hash_sorted=sort %hash; my $st=time; $db->import(\%hash_sorted); my $et=time; my $deltatime=$et-$st; say "Time required to write hash using DBM-Deep: $deltatime secs"; $st=time; store(\%hash_sorted,"c:/testpad/collector.storable"); $et=time; $deltatime=$et-$st; say "Time required to write hash using Storable: $deltatime secs";


The result is as follows:

Storable: under a second elapse time and a file size of 36.9K
DBM::Deep: 15 secs and a file size of 4.0 megs

The overhead in cpu and file size with DBM::Deep seems excessive to me. Any comments? Is this what to expect from DBM::Deep or any other DB package? Are there options I have missed?

I would appreciate any insight you can provide.


In reply to DBM::Deep overhead by perlpipe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.