I'm trying to work out a code in C language using simple API provided in distro. My goal is to write short rows to db, so that another process would read them as soon as possible. I therefore close DB as soon as writing any row is complete to unlock the db, so that another process would be able read this row. The task would be thought complete as I got the code working, but.. the speed of row insert slows down very soon. We'd start with ~50 inserts per sec, and in a minute the maximum will be no more than 10 inserts per second. I tried to figure out the reason and I found out that every insert will make its own small SST file, with just one row, and if I switch on the WAL and then avoid flush, there would be too many wal log files, also with just one row. There would be also ~2000 "LOG.old" files per second, each doubling and redoubling the list of options - and this is what i think make the whole thing work so slow. First I tried to avoid flushing, then I tried to induce periodic flushing, but that was all no use. I wonder, if there are any options to be able to close and open the db many times for writing, but still not to create an SST or WAL file each time we do it?
Asked
Active
Viewed 1,412 times
0
-
You should somehow disable all levels except for L0 to get what you want. (Suppose you're on leveled compaction) – user10750081 Dec 07 '18 at 06:43
1 Answers
1
Does not seem like you should be using rocksdb for that the way you are doing it now. If you have the DB open for such a short time, it can't run compactions and all your data will remain in the WAL or in level 0. Just the overhead of opening all the files that hold the non-compacted SSTs is high and all level 0 SSTs have to be scanned on read, because they are internally ordered, but have no order in the level, which will make rocksdb slow on read.
You should probably use a daemon-based database/store (memcached?) and just communicate via IPC (unix-socket?) from the processes, because opening a database is always slow for a single read/write.

midor
- 5,487
- 2
- 23
- 52