1. cache 容量的规划
$ ./calBdb.sh 2000000 64 256 128
Inputs: records=2000000 keySize=64 dataSize=256 nodeMax=128 density=80% overhead=10%
Cache Size Btree Size Description
-------------- -------------- -----------
219,994,975 197,995,478 Minimum, internal nodes only
259,343,313 233,408,982 Maximum, internal nodes only
877,772,753 789,995,478 Minimum, internal nodes and leaf nodes
917,121,091 825,408,982 Maximum, internal nodes and leaf nodes
Btree levels: 4
./calBdb.sh 10000000 64 256 128
Inputs: records=10000000 keySize=64 dataSize=256 nodeMax=128 density=80% overhead=10%
Cache Size Btree Size Description
-------------- -------------- -----------
1,099,974,877 989,977,390 Minimum, internal nodes only
1,296,716,566 1,167,044,910 Maximum, internal nodes only
4,388,863,766 3,949,977,390 Minimum, internal nodes and leaf nodes
4,585,605,455 4,127,044,910 Maximum, internal nodes and leaf nodes
对内存的需求还是不小的。10m ,1G.
2.transaction 太慢,难以忍受
3.防止, "phantoms" when not using transactions?
这个我遇到了,不过,我没有按照bdb 的提示解决。
boolean exists = false;
boolean done = false;
while (!done) {
OperationStatus status = cursor.putNoOverwrite(key, insertData);
if (status == OperationStatus.SUCCESS) {
/* A new record is inserted */
exists = false;
done = true;
} else {
status = cursor.getSearchKey(key, foundData, LockMode.RMW);
if (status == OperationStatus.SUCCESS) {
/* An existing record is found */
exists = true;
done = true;
}
/* else continue loop */
}
}
4.cache percetage 一定要设,否则, outofmemory .
5.bdb ,nio 的时候,不能用thread.currentthread.interupt() 停止thread .