in reply to What is a fast way to get keys of a Berkeley DB into an array?
You should use strict and warnings. Particularly
is not what you want.print ( $#keys + 1 ) . "\n";
Concerning you question, you're certainly hitting data pages, as you retrieving data values from database with c_get. Sorry, have no idea how to avoid this.
PS it looks like the following is slightly faster:
my $db = tie my %hash, 'BerkeleyDB::Btree', -Filename => 'data.dbm'; my @keys = keys %hash; print 0+@keys, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What is a fast way to get keys of a Berkeley DB into an array?
by mab (Acolyte) on Jun 09, 2010 at 19:24 UTC |