Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Berkely DB > $str or md5($st...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1782 of 1804
Post > Topic >>

$str or md5($str) use as key?

by "palexvs@[EMAIL PROTECTED] " <palexvs@[EMAIL PROTECTED] > Jan 18, 2008 at 06:23 AM

Few month ago I tested berkeley-db with various configurations (B-tree
or Hash, $str or md5($str) for key) and choose B-tree with md5($str)
for key.
But now tested again and get such result:
insert to emty DB 3041977 records
1. key - string whith ~72 chars ([A-Z0-9_-|]{1,72}).
200s - Btree
2000s - Hash
2. key - md5(string) 16 bytes
900s - Btree
1000s  - Hash
3. key - md5_hex(string) 32 chars ([A-F0-9]{32}).
1000s - Btree
1200s  - Hash

Why it's so?

Use very simple script:
#!/usr/bin/perl
use strict;
use warnings;
use 5.8.8;
use BerkeleyDB;
use Benchmark::Timer;
use Digest::MD5 qw/md5_hex md5/;

my $module = "BerkeleyDB::$ARGV[2]";

my $bdbp = new $module -Filename => $ARGV[1], -Cachesize => 100000000,
-Flags => DB_CREATE or die "File '$ARGV[1]' has no BDB format\n";
open(FH,'<',$ARGV[0]) or die "Can't open input file: $ARGV[0]\n";
my $ST;

my $t = Benchmark::Timer->new();
$t->start('ALL');

while(<FH>) {
    chomp();
    my $UUID = uc($_);
#    my $status = $bdbp->db_put(md5_hex($UUID),$UUID,DB_NOOVERWRITE);
#    my $status = $bdbp->db_put(md5($UUID),$UUID,DB_NOOVERWRITE);
    my $status = $bdbp->db_put($UUID,$UUID,DB_NOOVERWRITE);
}

close(FH);
undef $bdbp;

$t->stop('ALL');
print $t->re****t;
 




 2 Posts in Topic:
$str or md5($str) use as key?
"palexvs@[EMAIL PROT  2008-01-18 06:23:20 
Re: $str or md5($str) use as key?
adamgic@[EMAIL PROTECTED]  2008-01-20 22:54:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 6:35:38 CDT 2008.