When to use a key-value data store vs. a more traditional relational DB?

后端 未结 6 1414
谎友^
谎友^ 2020-12-24 10:53

When would one choose a key-value data store over a relational DB? What considerations go into deciding one or the other? When is mix of both the best route? Please provide

6条回答
  •  無奈伤痛
    2020-12-24 11:42

    If you want O(1) lookups of values based on keys, then you want a KV store. Meaning, if you have data of the form k1={foo}, k2={bar}, etc, even when the values are larger/ nested structures, and want fast lookups, you want a KV store. Even with proper indexing, you cannot achieve O(1) lookups in a relational DB for arbitrary keys. Sometimes this is referred to as "random lookups".

    Alliteratively stated, if you only ever query by one column, a "primary key" if you will, to retrieve the rest of the data, then using that column as a keyspace and the rest of the data as a value in a KV store is the most efficient way to do lookups.

    In contrast, if you often query the data by any of several columns, aka you support a richer query API for the data, then you may want a relational database.

提交回复
热议问题