Why use SS Tables instead of One-File per key in Key-Value Databases?

26 views Asked by At

I'm trying to understand the internals of databases and why certain design decisions were taken when I had a doubt.

Let's assume that the only requirement is to get the value given a key. No other access patterns to be supported.

If this is the scenario, why not just use one file per key in disk instead of going the traditional LSM Tree + SS Table approach? Inserts would be O(1) since you create a new file and search will also be O(1) since we know if the file is present in the disk or not.

I understand there must be some reason to not use this approach, but I'm not able to visualise what that reason would be.

One reason I could think of is that data in disk is stored in blocks and blocks when retrieved from disk are cached. Now, in most cases, this reduces disk I/O. Seeking in an already open file is also faster than fetching the file from disk, but again, this is optimal only in average cases.

In worst cases, since the number of SS Table files will be much lower than the number of files when storing one file per key, Disk I/O will still be lower.

Are there any other reasons why we don't store one file per key other than Disk I/O?

0

There are 0 answers