1

I use kyotocabinet hashdb for search by hashes. I have been put 10 millions fields to hashdb and searched 1000 random hashes for 78 milliseconds. After some time i tried again and it took around 40 seconds. I thought that kyotodb load array bucket to RAM and then search. After each search it stay faster and faster, but still slow ~ 5 sec. Also it doesn't work with 2 different threads.

Here is my code on java:

long a = System.currentTimeMillis();

DB db = new DB();
int cnt = 0;

// open the database
if (!db.open("m10.kch#bnum=10000000#msiz=1024000000", DB.OWRITER | DB.OCREATE)) {
    System.err.println("open error: " + db.error());
}

for (int j = 0; j < 10; j++) {
    long ts = System.currentTimeMillis();
    for (int i = 0; i < 1000000; i++) {
        db.set(getRandomKey(cnt), getRandomVal());
        cnt++;
    }

    long te = System.currentTimeMillis();
    System.out.println("million added " + (j + 1) + " for " + (te - ts));
}

for (int i = 0; i < 1000; i++) {
    System.out.println(db.get(getRandomKey((long) (Math.random() * cnt))));
}

db.close();
long b = System.currentTimeMillis();
System.out.println("total = " + (b - a)); // here i take 78msec or 40sec or 5 sec

What is wrong with it? Or it is normal speed for searching by 10 million? I do not see O(1).

Tsung-Ting Kuo
  • 1,171
  • 6
  • 16
  • 21

0 Answers0