Cayley and cockroachdb


It seems that cockroach Postgres interface is not 100% compatible.
I didn’t test this example but I think it would be interesting to use Cayley with Cockroachdb.

Can you provide some specifics? Neither this post nor the linked one provide any actionable detail about the underlying issue, and we don’t currently have the resources to dig into this from scratch.

Yes, CockroachDB is not 100% compatible with Postgres. I’m not aware of any claims that it is. Hopefully whatever incompatibilities preventing using CockroachDB with Cayley will not be difficult to fix, but this isn’t on our roadmap at the moment. A bug report with more specifics would be appreciated.


oke, I understand.

I shall test the connection Cayley - cockroachdb, because I read the
problem on the Cayley site.

For what it’s worth, it looks like one of the primary blockers preventing Cayley from running on CockroachDB is their use of partial indexes, seen here. @peter, correct me if I’m wrong, but I don’t think we have any plans to support partial indexes in the near future.

Partial indexes are not on any near-term roadmap. I’m not aware of any particular challenge in implementing them, though. I’m curious what Cayley uses them for. You’d want to avoid indexing a significant fraction of rows to make the partial index worthwhile.

From the link Nathan posted, they’re just avoiding indexing NULL values. Functionally speaking, it should be equivalent to use a full index. We could simply ignore the WHERE clause for now.

Ah, didn’t click through that link. Interesting that Cayley creates two indexes with the only difference that one doesn’t contain a column that might be NULL. Couldn’t they just index the NULL column, or are there surprises there when using Postgres?

In SQL, two null values are considered distinct from each other, so if these two partial indexes were combined, the database would allow duplicate rows for (subject_hash, predicate_hash, object_hash) if label_hash were null. Using two partial indexes works around this by enforcing the uniqueness constraint separately for cases where the label_hash column is and is not null.

1 Like

As @bdarnell correctly mentioned, the only reason why we use this partial index is because of NULL values in label_hash column.

And as a note, Cayley will support CockroachDB in the next release. Most changes are already done. The main blocker right now is JOIN support. We may disable it for Cockroach and do full table scans instead, as temporary solution.

We are also considering using KV API directly, since it makes things easier from our perspective. Or it might be even better to use “Structured data API” mentioned by Cockroach team in few videos. Is it exposed somewhere?

1 Like