Given this bit in your snippet of code:
... tie %database, ... ... $database{$h->{id}} = $dump; ...
It would seem that your intention/requirement is simply to fetch a chunk of data by means of a look-up key/id string. (That is, you don't need to search on the basis of the data content associated with the key/id.)

If that's true -- and if it's also true that the data content linked to each key/id remains static -- then it might suffice to have the full (2+GB) data file in whatever form is most convenient generally (assuming this is read-only), and build a separate index (e.g. with Berkeley DB) in which each key/id string is associated with the byte offsets for the associated data chunk in the big file.

It would be quick and easy to do one pass over the big file to create a separate listing of key/id strings with the byte-offsets of their associated records (e.g. start_byte, n_bytes). Then build a DB_File (or equivalent) index of the keys and byte-offsets (instead of keys and data blocks).

Depending on how many records you have, a full hash of key+byte_offset pairs might even fit in ram...


In reply to Re: DB_File/BerkeleyDB with large datafiles by graff
in thread DB_File/BerkeleyDB with large datafiles by Lowry76

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.