datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
oconn 2019-10-16T15:16:09.010400Z

Looking for some advice for working with Datascript in a re-frame application. First: I’ve taken a look at re-posh and like what it’s doing, but got to wondering if there was something out there that just handles creating the ratom wrapper around the datascript connection and is a little less opinionated? I’d like to use the datascript API directly which is one reason why I’m leaning away from re-posh. Second: Any performance considerations, benchmarks, or advice for medium to large size applications? We do have users running our app on older windows devices so I want to be considerate of that.

unbalanced 2019-10-17T12:17:44.011900Z

here's one more alternative for you that works very similarly: https://github.com/jjtolton/rocinante/blob/master/src/clj/new/rocinante/src/cljs/base/lib/data/ds.cljs

❤️ 3
oconn 2019-10-21T13:41:28.015800Z

Thanks for these!

kenny 2019-10-16T15:26:33.010500Z

We use Datascript and posh in our application. It works well. I don't particularly like posh -- it's quite bloated -- but it gets the job done. You can exactly as you say and create a Datascript connection and add a listener to it. That listener will be called anytime a transactionn occurs. You'd then need to update all your ratoms. There is a performance consideration there. That is what posh helps with -- it figures out exactly which ratoms change and only updates those. Figuring out the ones that change is not trivial. Posh's approach is also not perfect.

oconn 2019-10-16T15:31:43.010700Z

Yeah saw that it manages an ratom map. Overall - that was my take away. On the datascript side, have you seen any performance issues. I’ve seen in some of the GH issues with users saying that it can be up to 10x slower then a direct lookup? This also seems to be with more involved queries?

oconn 2019-10-16T15:33:12.010900Z

https://github.com/tonsky/datascript/issues/130

kenny 2019-10-16T15:36:49.011200Z

No. Our application certainly does not pull in entities at that scale though. You're trading off performance for query flexibility. We chose DS as the store because it is far easier to interact with than updating nested maps. We also use Datomic on the backend so having a similar DSL for transactions is nice.

oconn 2019-10-16T15:39:24.011400Z

Thanks for the feedback!

jbrown 2019-10-16T20:09:39.011600Z

We use datascript for our application, but not reframe. Our datascript dbs are usually quite large (often more than 10,000 entities) We used to use posh, but ran into some performance problems with it and wanted to use the whole datascript api, so we built our own reactive wrapper around datascript similar to https://github.com/hiposfer/rata/blob/master/src/hiposfer/rata/core.cljs (happy to post the code if you want a look). We found for our use case it's faster to rerun all registered lookups than use posh. We also found queries and pulls to be significantly slower than entity lookups, so we only use queries/pulls when they are absolutely necessary (the datoms api is also very fast).

❤️ 1