Live data from Hacker News

LevelDB: a fast and lightweight key/value database library

code.google.com

31–40 of 82 posts

Re: LevelDB: a fast and lightweight key/value database library

#31

What I would like to know is, is there support accessing values by nth-largest key? I had to roll my own b-tree library specifically to get this feature since nothing out-there had it.

Why not index size(key)?

Then lookup the n-th largest key and then pull the values?

eg. SELECT value from key_value_pairs order by size(key) LIMIT N

Re: LevelDB: a fast and lightweight key/value database library

#32
post #16

This looks like it has similar goals to bitcask. The tradeoffs and differences would be nice to know.

leveldb is a persistent ordered map; bitcask is a persistent hash table (no ordered iteration). bitcask stores a fixed size record in memory for every key. So for databases with large number of keys, it may use too much memory for some applications. bitcask can guarantee at most one disk seek per lookup I think. leveldb may have to do a small handful of disk seeks. To clarify, leveldb stores data in a sequence of lev…

I just need to say - it's pretty cool to see Sanjay Ghemawat hanging out on HN.

Re: LevelDB: a fast and lightweight key/value database library

#33
post #29

Earlier quoted context omitted.

One of the leveldb authors here. TokyoCabinet is something we seriously considered using instead of writing leveldb. TokyoCabinet has great performance usually. I haven't done a careful head-to-head comparison, but it wouldn't surprise me if it was somewhat faster than leveldb for many workloads. Plus TokyoCabinet is more mature, has matching server code etc. and may therefore be a better fit for many projects. Howev…

Did you consider fractal trees? http://tokutek.com/presentations/bender-Scalperf-9-09.pdf

Is there a more useful technical paper on Fractal Trees? Better yet is there a open source implementation of the same?

Re: LevelDB: a fast and lightweight key/value database library

#34
post #16

This looks like it has similar goals to bitcask. The tradeoffs and differences would be nice to know.

leveldb is a persistent ordered map; bitcask is a persistent hash table (no ordered iteration). bitcask stores a fixed size record in memory for every key. So for databases with large number of keys, it may use too much memory for some applications. bitcask can guarantee at most one disk seek per lookup I think. leveldb may have to do a small handful of disk seeks. To clarify, leveldb stores data in a sequence of lev…

Also worth noting: bitcask is written in erlang and leveldb in c++.

Re: LevelDB: a fast and lightweight key/value database library

#35

Earlier quoted context omitted.

Based on their numbers it looks slower than TokyoCabinet but still much faster than BerkleyDB. Would need to design a head to head benchmark. I don't think Redis is a good comparison as that's an in-memory database so better suited for the 10% of hot data you'd need to cache. Whereas disk stores like TokyoCabinet and LevelDB would be great for storing the other 90-100%. If your use case involves a large dataset and y…

One of the leveldb authors here. TokyoCabinet is something we seriously considered using instead of writing leveldb. TokyoCabinet has great performance usually. I haven't done a careful head-to-head comparison, but it wouldn't surprise me if it was somewhat faster than leveldb for many workloads. Plus TokyoCabinet is more mature, has matching server code etc. and may therefore be a better fit for many projects. Howev…

Have you looked at implementing CAS? It is the one thing missing for me to adopt it as a underlying store for my AvroBase API: http://www.javarants.com/2010/06/30/havrobase-a-searchable-e...

Re: LevelDB: a fast and lightweight key/value database library

#36
This could be great news for iOS. AFAIK, this is the first K/V DB that could be built for iOS (c++) and has a free license that is compatible with the AppStore (Tokyo Cabinet uses LGPL and the author has shown no interest to me in adding a static linking clause, Berkeley DB requires an expensive commercial license, etc).

Re: LevelDB: a fast and lightweight key/value database library

#37
post #6

Anybody know what hardware those benchmarks were on? Is it actually durable? They mention problems with writeback caching, but are they at least durable from the OS perspective? How well does it scale?

It is durable from an OS perspective. I started typing in a long explanation, but I think the comment for the "sync" field in the options.h file captures things well: struct WriteOptions { // If true, the write will be flushed from the operating system // buffer cache (by calling WritableFile::Sync()) before the write // is considered complete. If this flag is true, writes will be // slower. // // If this flag is fal…

Writes being lost means what, a trashed file? Or merely an incomplete one?

Re: LevelDB: a fast and lightweight key/value database library

#38
post #34

Earlier quoted context omitted.

leveldb is a persistent ordered map; bitcask is a persistent hash table (no ordered iteration). bitcask stores a fixed size record in memory for every key. So for databases with large number of keys, it may use too much memory for some applications. bitcask can guarantee at most one disk seek per lookup I think. leveldb may have to do a small handful of disk seeks. To clarify, leveldb stores data in a sequence of lev…

Also worth noting: bitcask is written in erlang and leveldb in c++.

Technically bitcask is a combination of Erlang and C.

Re: LevelDB: a fast and lightweight key/value database library

#39

Earlier quoted context omitted.

It is durable from an OS perspective. I started typing in a long explanation, but I think the comment for the "sync" field in the options.h file captures things well: struct WriteOptions { // If true, the write will be flushed from the operating system // buffer cache (by calling WritableFile::Sync()) before the write // is considered complete. If this flag is true, writes will be // slower. // // If this flag is fal…

Writes being lost means what, a trashed file? Or merely an incomplete one?

Merely an incomplete one. Leveldb never writes in place: it always appends to a log file, or merges existing files together to produce new ones. So an OS crash will cause a partially written log record (or a few partially written log records). Leveldb recovery code uses checksums to detect this and will skip the incomplete records.

Re: LevelDB: a fast and lightweight key/value database library

#40
post #31

What I would like to know is, is there support accessing values by nth-largest key? I had to roll my own b-tree library specifically to get this feature since nothing out-there had it.

Why not index size(key)? Then lookup the n-th largest key and then pull the values? eg. SELECT value from key_value_pairs order by size(key) LIMIT N

I don't get it,

How would you use this approach to find say, the 195687th largest element in O(log(n)) time?

Edit: However, I do know I can write a SQL query to find this - an ordinary index plus limit should do this. It's just such an approach gets really awkward and so unpredictable when you are dealing with a lot of distinct columns and tables - why I implemented this with key-value DB (a custom index on top of Kyoto Cabinet).

Post reply on HN