:db.fn/cas
(#264)distinct
aggregate returns set not a vector (thx @jdf-id-au)datascript.arrays
, datascript.btset
and datascript.Datom
type has changedPerformance optimizations for JVM version:
[persistent-sorted-set "0.1.0"]
Numbers I get on my 3.2 GHz i7-8700B (median time per test, ms):
version | add-1 | add-5 | add-all | init | retract-5 | q1 | q2 | q3 | q4 | qpred1 | qpred2 |
---|---|---|---|---|---|---|---|---|---|---|---|
0.17.1-jvm | 795.8 | 670.7 | 651.8 | 79.4 | 617.5 | 2.3 | 5.4 | 8.2 | 13.1 | 7.1 | 27.3 |
0.18.0-jvm | 625.2 | 450.9 | 401.8 | 21.8 | 389.5 | 1.9 | 5.4 | 8.2 | 13.3 | 7.3 | 28.9 |
0.9.5703-datomic | 1693.9 | 737.9 | 528.5 | --- | 1420.9 | 2.8 | 5.2 | 7.3 | 9.3 | 12.8 | 15.5 |
0.18.0-v8 | 1231.6 | 963.1 | 930.3 | 76.5 | 809.1 | 6.4 | 15.2 | 23.8 | 33.6 | 24.2 | 24.5 |
Tests are as follows:
Test | Description |
---|---|
add-1 | Add 100k datoms to an empty DB, one datom per transaction |
add-5 | Add 20k entities to an empty DB, 5 datoms per transaction, 100k datoms total |
add-all | Add 20k entities to an empty DB in a single transaction, 100k datoms total |
init | “Fast” datascript DB creation from an already sorted array of datoms (used in DB deserialization), 100k datoms |
retract-5 | Retract 20k entities from a DB with 100k datoms. Each entity removes 5 datoms. 1 entity per tx. |
q1 | Query with 1 clause over a DB with 100k datoms, ~12k tuples in resultset [:find ?e :where [?e :name "Ivan"]] |
q2 | Query with 2 clauses, 1 join, ~12k tuples [:find ?e ?a :where [?e :name "Ivan"] [?e :age ?a]] |
q3 | Query with 3 clauses, 2 joins, ~6k tuples [:find ?e ?a :where [?e :name "Ivan"] [?e :age ?a] [?e :sex :male]] |
q4 | Query with 4 clauses, 3 joins, ~6k tuples [:find ?e ?l ?a :where [?e :name "Ivan"] [?e :last-name ?l] [?e :age ?a] [?e :sex :male]] |
qpred1 | Query with a predicate, ~50k tuples [:find ?e ?s :where [?e :salary ?s] [(> ?s 50000)]] |
qpred2 | Query with a predicate and dynamic input, ~50k tuples [:find ?e ?s :in $ ?min_s :where [?e :salary ?s] [(> ?s ?min_s)]] |
For Datomic an datomic:mem://
database was used.
What we see:
or
, or-join
, not
and not-jon
support in queries (#238, #50)clojure.data/diff
on datascript/DB
(#281):as
in Pull API an attr-with-opts syntax (#270, PR #271, thx @Jumblemuddle){":db/id"}
in transactions (#228, thx @serebrianyi)0.16.9-aot1.7
, 0.16.9-aot1.8
, 0.16.9-aot1.9
). Main DataScript artifact has no AOTed code (related: #241, #279, #280)perf
from datascript.query-v3
(closes #272)rseek-datoms
(#253, PR #254, thx Jeremy Taylor)contains?
to built-ins (#211)datascript.core
to enable dead code elimination (#191). This should only affect you if you were using DataScript from JS and were importing datascript.core
directlyvector
, hash-map
, array-map
, list
and set
to built-in query functions (PR #186, thx Linus Ericsson):db.unique/value
too (issue #171)init-db
(issue #165)get-else
throws if nil
is used for default valueinit-db
sets correct max-eid
when processing facts about transactions (PR #164, issue #163, thx Nick Alexander):db/add
datascript.core
symbols to externs so they can be called directly from JS (e.g. in combination with mori, issue #139)reset-conn
, conn-from-datoms
and conn-from-db
(issue #45)get-some
returns [attr value]
instead of just value
(#143, same as Datomic)nil
from query function filters out tuple from resultcount
(#142) and subs
(#111)[<attr> nil]
) resolve to nil (#140)?
prefix (#136, #122)nil
as old value in :db.fn/cas
(PR #127, thx Petter Eriksson)conn?
will check that value is derefable instead of checking for (instance? Atom)
datascript.core
, not datascript
datascript.core
(internal namespace) was renamed to datascript.db
datascript.shim
(internal namespace) was renamed to datascript.arrays
Motivations:
Migration procedure:
(require '[datascript :as d])
to (require '[datascript.core :as d])
and you’re good to go.For the sake of easy migration, there’re no other changes in this release. Just renamings.
contains?
is called with an entity (PR #114, thx Kevin Lynagh)db-init
respects :db/index
property[ BREAKING ] Introducing new :db/index
schema attribute:
Attributes are not put to AVET by default anymore
Following attributes are put to AVET:
:db/index true
:db/unique :db.unique/identity
:db/unique :db.unique/value
:db/valueType :db.type/ref
All attributes put to AVET should be comparable. Note: maps and list are not comparable by default, vectors are compared value-by-value
[ BREAKING ] Min/max aggregation functions will only work on a comaparable values
Benefits:
:db/index
and do not make it :db.cardinality/many
Caveats:
:db/index
attribute, but it’ll be slowerMigration procedure:
datoms
, seek-datoms
calls with :avet
index, and index-range
call[?free-var <constant-attr> <constant-value>]
:db/index true
in the schemapull
, pull_many
, entity
(#94, thx Matt Senior)This release brings a significant performance boost for JVM version of DataScript (numbers are in comparison to JS/v8 version):
transact
: ~3 times fasterinit-db
: ~3–4 times fasterExperimental support for Clojure on JVM:
sorted-set
instead of BTSetget
lookup in queryinit-db
Performance numbers so far (raw data):
transact
: ~3.5–4 times fasterinit-db
: ~2–2.5 times slowerequiv
: ~5 times slowerhash
: ~10 times slower*.cljc
sources do not conflict with Clojure now. Code compiles under [lein-cljsbuild "1.0.6"]
init_db
in js (issue #73):in
and fn-clause
bindingsdatascript.core/DB
Datom
and DB
tag readers to cljs.reader/*tag-table*
, do not rely on data_readers.clj
:where
patterns (issue #53)pull
form in :find
clause:db/unique
constraintsentid
function:find [?e ...]
, tuple :find [?e ?v]
, and scalar :find ?e .
:db/isComponent
(issue #3)transact!
(also fixes #38)aggregate
keyword): (q '[:find (aggregate ?myfn ?e) :in $ ?myfn ...])
. Built-in aggregates work as before: (q '[:find (count ?e) ...]
entity
when passed nil eid (issue #47)datoms
/seek-datoms
/index-range
calls) now support fast reverse iteration via reverse
.(datascript/datom e a v & [tx added])
call for creating new datomsavg
, median
, variance
, stddev
and count-distinct
(issue #42, thx @montyxcantsin)min
and max
aggregates use comparator instead of default js <
comparisonfilter
init-db
for fast creation of DB from existing datoms (useful for e.g. initialization from serialized state)transact!
(~20%) and initial database population (init-db
, db-from-reader
, ~800%)deps.cljs
— no need to manually specify externs when using datascript dependencydatascript.js
to datascript
:db/current-tx
instead of entity id (issue #32)TxReport
: (get-in tx-report [:tempids :db/current-tx])
transact!
) and read it in listener callback (:tx-meta
key of TxReport
) (issue #32):db.fn/cas
transaction function (issue #20, thx @montyxcantsin)get-some
, get-else
, misssing?
query functions (issue #21, thx @montyxcantsin)touch
breaking entity cache (issue #17)ground
fn (issue #25):db.fn/retractEntity
(issue #18)Cosmetic changes to better mimic Datomic API. Useful for sharing code between Datomic and DataScript:
tempid
, resolve-tempid
, db
, transact
, transact-async
, index-range
, squuid
, squuid-time-millis
transact
to with
, with
to db-with
equiv
and hash
, Datom’s hash
touch
call accessible through datascript
namespace:db.cardinality/many
attributesProper entities implementation:
:db/valueType :db.type/ref
, its value will be automatically expanded to entites, allowing for recursive exploration of entities graphs (e.g. (-> (d/entity db 42) :parent :parent :children)
)(:person/_friends (d/entity db 42))
):externs [datascript/externs.js"]
Big performance improvements:
($db follows ?e1 ?e2)
)datoms
and seek-datoms
API calls:db.fn/call
(thx @thegeez)entity
addedCan you improve this documentation? These fine people already did:
Nikita Prokopov, Matt Senior, Thomas Heller, Ryan Belohlavek, Alexander Solovyov & Kevin J. LynaghEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close