
SQL in CockroachDB: Mapping Table Data to Key-Value Storage (2015) - jxub
https://www.cockroachlabs.com/blog/sql-in-cockroachdb-mapping-table-data-to-key-value-storage/
======
dang
From 2017:
[https://news.ycombinator.com/item?id=14728489](https://news.ycombinator.com/item?id=14728489)

Discussed at the time:
[https://news.ycombinator.com/item?id=10227516](https://news.ycombinator.com/item?id=10227516)

------
willvarfar
I am surprised that they have a way to serialize compound keys but they don’t
serialize the non-primary fields into a single value. Why wouldn’t that be
obviously easier?

They have the primary key fields serialized in the key so they need code to
make a match pattern against it etc. If the value contained the entire non-
primary fields in the exact same format then that same pattern code could be
used to evaluate where clauses on those fields too etc.

I would anticipate it also being massively massively faster and dramatically
reduce write amplification etc.

~~~
jordanlewis
CockroachDB no longer stores each non-primary-key column in a separate value
by default - you're right that that's less efficient than necessary.

You can now explicitly specify the layout of your table data across keys via
CockroachDB _column familes_ :
[https://www.cockroachlabs.com/docs/stable/column-
families.ht...](https://www.cockroachlabs.com/docs/stable/column-
families.html)

By default, since several years ago, all data in a table is stored in the same
column family.

------
spatial_dima
“CockroachDB is the only database in the world that enables you to attach
‘location’ to your data at the row level”

^ this statement is so false

~~~
SamReidHughes
Was it false in 2015?

