The API is very good but they made a couple of mistakes. A big one is that they defined a standard encoding for keys (tuple layer) but not for values. Binary keys/values are a bad abstraction, which they clearly recognized in the key case but not the value case. As a result Apple’s own record layer uses Protobufs.
There are two problems with this. First it hurts interop between potential layers, which is unfortunate. But second it makes it very hard to do predicate pushdown, which is very important for a distributed database. You can’t push a filter down to the storage layer if the storage layer has no idea what it stores!
And the tuple encodings are not suitable for values because they have to be parsed in full to be decoded. Which is necessary for sorting and fine for keys (which are small), but would be very bad for row values as you have to decode the entire thing just to read one column out of the middle. What you really want is a header with the value offsets up-front.
The solution, I think, is to define a record encoding to go along with the key encodings. I think it should (logically) be an ordered map integer => value where values are typed. Then you define a header up front with a format like type, id, offset, length?. Similar to protobuf etc.
Integer field ids are sufficient, schemas and so on can be managed by layers, either hard-coded or dynamic (you’re familiar with this!) schema management depending on the use-case.
I know where you’re coming from here, but the relational model necessitates some amount of query planning to satisfy data independence. We have discussed this before, though at the time I don’t think I realized this was spelled out so explicitly in the original Codd paper.
I think the planner can be kept fairly simple, though. I would argue even your ecto_fdb index selection logic constitutes a degenerate query planner (though it does not achieve independence).
Even more important is ensuring some sort of escape hatch. I don’t mind the Postgres planner 90% of the time, but then every so often it just refuses to use the indexes that I know are better and that just drives me insane.






















