Hacker News new | past | comments | ask | show | jobs | submit login

I'm trying to learn datalog casually, there's lots of queries that I still don't know how they translate

I.e. group by, window aggregates, order by, limit

I'd be interested in seeing the equivalent datalog that Crux makes given some of those statements for learning what efficient datalog looks like for some of those problems




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...


I highly recommend http://www.learndatalogtoday.org/ as a learning resource.

I also enjoyed this talk: https://youtu.be/oo-7mN9WXTw though it’s not so much about syntax as the logic of it.


Just finished watching that talk, I recommend it too! Information dense and fast with lots of useful examples on how to use Datalog, especially comparing it to what most programmers use today such as relational, key/value and document stores.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: