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 > Re: $str or md5...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 1782 of 1805
Post > Topic >>

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

by adamgic@[EMAIL PROTECTED] Jan 20, 2008 at 10:54 PM

On Jan 18, 10:23 pm, "pale...@[EMAIL PROTECTED]
" <pale...@[EMAIL PROTECTED]
> wrote:
> 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;

seems hash method has a weaker performace than btree when data sets is
small, but i don't know how large the data sets have to be to make
hash a better choice.
 




 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
tan12V112 Fri Oct 10 12:54:35 CDT 2008.