Better HN
topnewbestaskshowjobs
Log inSign up

refset

1,514 karma · joined Aug 24, 2015 (11y ago) · 537 submissions

https://github.com/refset

[ my public key: https://keybase.io/refset; my proof: https://keybase.io/refset/sigs/pyTK0thu8g5O4Zs7EA3HrQYKkYZjeEz_TUr8nZV2hlY ] c0ba44896414421c9009bc8a77a86ceb

meet.hn/city/51.0612766,-1.3131692/Winchester

Socials: - github.com/refset

---

Submissions

comment 6y ago · link · parent

:) well I already answered your same question on r/Clojure but here's a link for others: https://www.reddit.com/r/Clojure/comments/i3gzxy/crux_sql/g0...

comment 6y ago · link · parent

1) availability of valid time for domain as-of queries

2) performance of ad hoc as-of queries

3) ingestion throughput (RocksDB is _fast_)

4) eviction/excision throughput

5) a lazy query engine doesn't demand so much memory (because there is no need to hold entire intermediate result sets at the same time), and automatic join re-ordering makes the Datalog inherently more "declarative"

6) use of protocols for modularity allows you to create a massive range of possible topologies to support the non-functional requirements of your host environment

7) benefit from the RocksDB roadmap (or other embedded KV storage - see LMDB / rocksdb-cloud)

8) absence of a prescriptive data model

On the flip side:

1) absence of a prescriptive data model (though transaction functions can give you equivalent power)

2) API maturity

3) lazy caching of data at peers (vs Crux' fat nodes, though again, see rocksdb-cloud for one possible resolution)

4) query features: multiple data sources, lazy entity API, other niceties

There are definitely things still missing from both lists :)

comment 6y ago · link · parent

A thoroughly-validated canonical example problem hasn't emerged just yet, but there are many intersecting domains...

Temporal graph analysis of "evolving graphs" is an active research field with some strong motivating use-cases, for instance: profiling networks of fraudulent transactions across N bank accounts with data pulled from M source systems. This paper discusses the analysis of research citations over time, as another example: https://pdfs.semanticscholar.org/110b/0db484a1303eda30aa7e34...

That said, Crux's indexes aren't optimal for making all kinds of analytical time-range queries efficient just yet. Instead Crux is currently focussed on point-in-time queries, but the temporal R&D is still happening as it feels very ripe.

Looking for examples more generally, I think wherever you have a meaningful use-case for a graph database you probably, eventually, will want to capture and model history. If you then find yourself with two or more such databases that you want to integrate, then you will greatly benefit from a bitemporal graph DBMS.

As a fun example, I like to envisage integrating our two federated evolving knowledge graphs. Imagine a tool for "networked thought" like Roam Research that could allow us both to visualise the evolving connections between our independently recorded thoughts, before, during and after this conversation. Graphs of knowledge encoded in time.

comment 6y ago · link · parent

(I am involved with Crux - sorry!)

I see 4 main reasons why someone may want to be aware of Crux:

- if you have a bitemporal problem

- if you have a graph problem, i.e. something you might initially look to Neo4j to help with

- if you want to use Datalog because it can make writing an application simpler

- if you are thinking of building something similar (immutable event log + indexes) and want to save time

Crux is very different from Cassandra (strong consistency, fat nodes, arbitrary joins etc.), but you could definitely use Cassandra in your Crux architecture.

The closest "yet another" comparison would be Datomic. Crux and Datomic both strive to reimagine what a "general purpose" DBMS should look like, with the primary goal being developer productivity/sanity, whereas Cassandra's goal is simply to be a highly-scalable document store.

Hope that helps!

comment 6y ago · link · parent

The context here is that we benchmark ourselves against the likes of Neo4j and RDF4J using SPARQL test suites, in particular WatDiv [0] and LUBM [1] which are specifically designed for stress testing various subgraph matching queries [2]. Therefore we had to translate the data sets and queries from RDF/SPARQL to edn/Datalog etc.

There is an open issue in regards more general RDF support with details on the kinds of things Crux would need to add: https://github.com/juxt/crux/issues/317

[0] https://dsg.uwaterloo.ca/watdiv/

[1] http://swat.cse.lehigh.edu/projects/lubm/

[2] https://en.wikipedia.org/wiki/Subgraph_isomorphism_problem

comment 6y ago · link · parent

You always have the option to wire together multiple Datalog queries using Clojure/JVM-lang-of-choice (the N+1 query problem doesn't affect Crux when embedded), but we are currently analysing the possibilities for a higher-level query API, potentially in a similar vein to Mongo's pipelines [0], where a sequence of "stages" is defined. In the ideal case there would be _closure_ in the intermediate steps of a pipeline such that the output to any given stage (including Datalog queries) is a fully-fledged graph in its own right.

As for your specific examples, Crux already implements an order-by+limit+offset combination that automatically spills to disk if needed, but for efficient pagination you would probably want to maintain additional pre-sorted value ranges. For basic aggregation we have an alpha API decorator that composes Clojure transducers to great effect [1].

[0] https://docs.mongodb.com/manual/reference/operator/aggregati...

[1] https://github.com/crux-labs/crux-decorators/blob/master/tes...

comment 6y ago · link · parent

As it happens there was a comment on a related issue about Dremio support [0] (which also uses Calcite) where someone shared that they got a Dremio driver working. I was able to fork their driver and get Metabase working against Crux in time for a live demo of the crux-sql module back in May [1].

I just switched the forked driver repo to public if anyone wants to test it out [2]. The Metabase driver docs are pretty straightforward to get things running. There's definitely work to be done though and I didn't get very deep into it really - but I hope to pick it up again soon!

[0] https://github.com/metabase/metabase/issues/5562

[1] https://youtu.be/StXLmWvb5Xs?t=996

[2] https://github.com/crux-labs/crux-metabase-driver

(I work on Crux :)

EDIT: it's also worth a mention that the linked issue #6230 discusses a lot of problems deriving from Druid's lack of support for prepared statements, but Crux and Dremio don't have that limitation. Although reading the most recent comment it looks like Druid may have overcome that hurdle now, so with a bit of luck there might now be more traction to get mainline Metabase support for a generic Calcite driver!

comment 6y ago · link · parent

I'm not sure EATV/AETV could be used fully instead of EAVT/AEVT as you would then lose the ability to have efficient range seeks across values. I do agree though that scanning all historical values in EAVT/AEVT is unsatisfactory for many use-cases as it makes the performance of ad-hoc as-of queries unpredictable.

By contrast, Crux [0] uses two dedicated temporal indexes: EVtTtC and EZC (Z-curve index) to make bitemporal as-of queries as fast as possible. These are distinct from the various triple indexes, which don't concern themselves with time at all. (Vt = valid time, Tt= transaction time, and C = the document hash for the version of an entity at a given coordinate)

[0] https://opencrux.com (I work on Crux :)

comment 6y ago · link · parent

Hi, I work on Crux :)

1) Crux is schemaless at its core, but you can build your own ~class hierarchy model using regular attributes and Datalog rules to differentiate between types of entities.

2) Subscribing to arbitrary Datalog without any form of polling requires a fundamentally different form of query algorithm (i.e. incremental view maintenance, as seen in Materialize), however there's a whole spectrum of possibilities available if you are willing to accept polling at some level. Hasura has quite an inspiring take on subscriptions that we may yet try to recreate on top of Crux: https://hasura.io/blog/1-million-active-graphql-subscription...

comment 6y ago · link · parent

Thanks for the explanations. That is a very intriguing use-case for foreign data wrappers!

comment 6y ago · link · parent

> temporal concepts should have been deeply native to SQL right to its core

Oh absolutely. I think the original intuition by Snodgrass et al. in TSQL2 to model temporality outside of the actual relational structure was a more promising direction, otherwise the complexity of composing joins across many tables, each with independent temporal versioning, seems rather overwhelming (note that the article doesn't discuss joins at all). Schema migration is another hairy topic that the 2011 standard barely addresses.

Modelling temporality outside of the database is what we've been pushing ahead with on Crux, which provides Datalog as the native query language but will imminently also support a simple bitemporal flavour of SQL for point-in-time querying (using Apache Calcite), where application & system time are defined by a single "as-of" prefix at the beginning of the statement that applies across the entire query: https://github.com/juxt/crux/tree/master/crux-sql#bitemporal... (queries over ranges and periods are currently out-of-scope)

comment 6y ago · link · parent

That sounds neat. What does the performance of querying past versions look like? For instance, is lookup time linear with the amount of history or do you maintain special temporal indexes?

comment 6y ago · link · parent

> I've always been bewildered why this wasn't a core part of SQL from the very beginning.

It's a long and messy history (no pun intended), but essentially it was rarely practical to consider retaining database history for the first few decades of SQL, due to physical storage costs & limitations. Snodgrass and Jensen proposed initial bitemporal extensions in the 90s and lot of research was done subsequently, but most vendors didn't make their move until the 2011 standard was formed (Oracle Flashback being the most notable exception). Unfortunately the rollout of the 2011 temporal standard has been underwhelming across the board, as each vendor ended up implementing something subtly different, which I think has massively hindered adoption. Since then I would guess that "immutability" has been the largest driving force behind the resurgence of interest.

comment 6y ago · link · parent

System time (aka "transaction time") is also invaluable for debugging if you annotate it with release versions. Unless an application is particularly strapped for storage costs, which is rare in this day and age, it ought to be the default choice to use built-in system time versioning wherever it exists.

comment 6y ago · link · parent

There was a ClojuRU 2019 talk about such a thing: https://youtu.be/Hf57HbRvYhM

436.

The Impossibility of Fast Transactions [pdf](infoscience.epfl.ch ↗)

1 points · by refset · 6y ago · discuss

comment 6y ago · link · parent

True, I was being somewhat pedantic. Whenever I see the word "db" I can't help but think "DBMS". It's frustrating that "DBMS" is such a mouthful that nobody bothers using it anymore, and that KV store projects choose to (ab)use the DB suffix.

> implementation details of the KV/heap layer with some meaningful transactional properties seem more interesting

There is undoubtedly a real beauty in LMDB's data structures, and it is impressive to see how Rockset have re-engineered RocksDB to become cloud-native …but my own feeling is that the SQL/whatever, distributed consistency and federation layers of a DBMS encompass some seriously hard and fascinating problems. What if the web could behave like a cohesive offline-first database for all of human knowledge after all?

Now I think about it, "interesting" has a pretty loose definition too!

comment 6y ago · link · parent

Embedded KV stores are as comparable to SQLite as Cassandra is to Postgres (i.e. lacking joins or other data modelling essentials), but I agree that embedding a database directly inside your app is interesting and opens up a world of possibilities for efficiently blending N+1 code and queries. It gets even more interesting to take it a step further and embed a networked-replica of a database à la Datomic Peers.

comment 6y ago · link · parent

Sounds like DataScript [0] could be a good fit for you. The Datalog query language is very powerful for writing recursive rules.

[0] https://github.com/tonsky/datascript

comment 6y ago · link · parent

Hi, I work on https://opencrux.com which is a close relative of Datomic but with different design goals (bitemporal + schemaless). It has a rich set of Datalog features, best exemplified in the tests: https://github.com/juxt/crux/blob/master/crux-test/test/crux...

comment 6y ago · link · parent

Are there any tools you recommend for DDD? Have you seen much justification for bitemporal or retroactive events, as in https://dddeurope.com/2018/speakers/thomas-pierrain/ ?

comment 6y ago · link · parent

Within Crux's new transaction functions you are able to run queries against the entire database and (very soon) also against speculative transactions, to enforce all manner of constraints and control whether the transactions succeed/fail. Schema-on-write is therefore a matter of funnelling all `put` & `delete` operations through these functions. I suspect someone could even create a library of transaction functions to emulate the entire Datomic data model, if so desired.

However, I still believe schema-on-read is more desirable in general though, as you can simply extend a query to only care about the AV combinations which conform to some definition for that A. The Calcite SQL integration we've been building works like this. Conformance could also be processed asynchronously and documents be labelled as "conformed" as/when to reduce the burden during general queries.

(also, hey!)

comment 6y ago · link · parent

Things have been moving quickly in recent months! We've already done some prototyping on a pull syntax (using EQL) and will start proper work on it after the 1.9 release is out.

Alongside some less-exciting changes 1.9 will include full transaction function support, so schema-on-write is much simpler to achieve now. It took us time figure out how to resolve it whilst not completely breaking bitemporality & eviction. Here are a few tests showing how it to use transaction functions now: https://github.com/juxt/crux/blob/b13b4da988ed7e91dc7685e5d5...

> documents are converted into EAVT for every attribute?

The indexes are certainly schemaless, which means that every document attribute gets turned into a set of one or more triples that can be joined against without needing to declare anything about the attributes upfront, but internally the indexes don't follow the same EAVT pattern you may be familiar with from Datomic etc. checkout the ClojuTRE talk (linked in these comments) for a good overview on roughly what the internal indexes look like. It's a little out of date now, but still gives a strong impression for how things work today.

comment 6y ago · link · parent

Any ideas what some of the challenger banks are using? I've not seen any examples beyond Nubank (~$10B valuation), who have bet big with Datomic: https://www.youtube.com/watch?v=VYuToviSx5Q

Also: https://www.datomic.com/nubanks-story.html

comment 6y ago · link · parent

The best place to start for context would be Håkan's ClojuTRE talk: https://www.youtube.com/watch?v=YjAVsvYGbuU

And here are the slides for that talk, which include a few references: https://juxt.pro/hakan-raberg-the-design-and-implementation-...

Feel free to reach out to the team, or find us on Zulip/Slack, if you want to hear more or just chat :)

comment 6y ago · link · parent

Well, I think Postgres will remain a very safe default choice in new projects for most organisations for a long time yet, because the skills to work with it are common and relatively cheap.

However, Crux is much easier to justify with stakeholders if you have a complex problem revolving around ad-hoc graph joins or bitemporal queries & audit requirements. Or if you simply have high single-threaded transaction throughput requirements. Postgres in particular doesn't have pleasant answers to this intersection of problems.

I think the tables will inevitably turn against currently-safe choices life Postgres though, as systems like Crux are going to continue to be able to take advantage of the latest and greatest ideas, relatively unencumbered by decades of antiquated design decisions and legacy code. This is where the whole Clojure philosophy really shines in Crux, as all the layers interact through clean and composable Clojure protocols that facilitate new kinds of database modularity. These protocols allow the community to take advantage of whatever wonderful cloud services they might want to use, without any additional ceremony to interact with the core development team.

EDIT: Finally, as new generations of developers emerge the pressure for the industry to standardise on a better relational query language will build. Fingers are crossed for Datalog!

comment 6y ago · link · parent

Indeed, it's an impressively eclectic product, considering how niche it seems to still be.

Incidentally they have some fairly nice materials about their own bitemporal query support and it's use across industries, e.g.:

https://www.marklogic.com/blog/bitemporal/

https://www.marklogic.com/resources/mifid-ii-its-about-data-...

comment 6y ago · link · parent

There's another thread on the homepage right now about Crux [0], which is a database designed specifically to be able to operate downstream from multiple legacy systems using bitemporal indexes to stitch everything together. This pattern is very common in banks e.g. for calculating and reporting on risk positions.

I expect you're right that this story is purely about using Mongo for downstream systems.

[0] https://news.ycombinator.com/item?id=23493163

comment 6y ago · link · parent

Aha, well it's certainly been a learning curve for me!

I found the public MIT lectures on "retroactive data structures" (by Erik Demaine) very helpful to clarify the mental model and properties of temporal databases. Point-in-time bitemporal queries are fairly simple compared to the kinds of things some organisations use data warehouses for (e.g. temporal range queries across N dimensions), but surprisingly few teams think about representing time so clearly within their transactional OLTP/HTAP systems, so even point-in-time queries seem more novel than they really should.

Everything is moving in the right direction though as immutable data becomes the default.

comment 6y ago · link · parent

These are definitely valid points, thanks. I would like to see Crux evolve into something more comprehensive like MarkLogic eventually, partly to not disappoint anyone with those common expectations of what a "document database" ought to have, but also because it feels like the right direction to move in if we want to see an offline-first world succeed in the future...and pick-up where Lotus Notes stopped innovating!

If we had native JSON support already I suspect we would have opted for "JSON Store", but we've only been able to support edn since we launched and "edn Store" isn't too helpful.

An official Lucene index is very likely going to be added for full-text search at some point. I know of two users in the community who have already integrated Lucene themselves, which is actually fairly straightforward as long as you don't need to do searches in the past or can cope with returning results from across all of time.

1
1415161718