leveldb
leveldb copied to clipboard
leveldb write slow after database is large?
Hello, I encountered some problems when using leveldb. The scenario is like this: I kept writing key value to the database. At first, it was very fast, but after writing for an hour, I found that the writing became slower and slower. Before each write, it will query whether the key exists. The key value written is only tens of bytes, but eventually hundreds of terabytes of data will be written. Is the speed of this write affected by the size of the database?
Keeping put data into leveldb at full speed will soon make the memtable and level0 full. Just as in db/db_impl.cc line 1320 Status DBImpl::MakeRoomForWrite(bool force), the write operation will wait for background task to make sure the level0 will not increase without control.
I write a demo to test if the size of db will influence the write speed, the conclusion is no. In the demo, I separately run write operations, For example for(int i=key;i<key+1000000;++key){ db->Put(leveldb::WriteOptions(),"key"+std::to_string(key),"value");} based on previous big db for several non-overlap intervals, and the using time does not show such a relationship.
As I have seen in v1.22 every time I write in the same pair it gets written to temporary x.log file, so if it looks it up then why does it store the same data in the log?
My work around was to manually check is exists or not.