If the values in the index nodes are actual keys and not some analyzed version of them (which is what I was incorrectly calling the hashed key) then it seems there would be a way to construct the keys in the db by only visiting the index nodes.

Berkeley's BTree DBs are actually B+Trees, where all the values (*), are kept in the leaf nodes along with their respective keys. In-order traversal is done by locating the leaf block for the 'lowest' key, and then following peer-level pointers to move from leaf to leaf. Therefore, traversing the entire key-space will mean reading all the keys & values from disk.

(*)Unless the data values are too large to store in the chosen page-size, in which case 'overflow records' are used.

The concern is maintaining coherency and that's why I was hoping to avoid it.

If you use the tied hash interface, you could override the STORE() and DELETE() methods to maintain the key list entry. You could also use the fact that BDB allows you to maintain more than one DB in a single file to store that list as the only record in a second DB. That ought to ensure that single record is perpetually cached.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re^3: What is a fast way to get keys of a Berkeley DB into an array? by BrowserUk
in thread What is a fast way to get keys of a Berkeley DB into an array? by mab

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.