tonsky / tonsky/datascript

Why are Datascript queries so slow?

Open
#130 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
5.8k
Forks
318
PR merge metrics
No merged PRs in 30d

Description

The benchmark query q4 takes 40 milliseconds to execute on a 20000 entities database on the JVM (even longer in CLJS).

By contrast, a lookup in a Clojure map of 20000 maps with the same data takes 300 nanoseconds on the JVM. Why does it take 100000 times more in Datascript?

I understand that multiple lookups in the index trees are necessary in order to filter by gender and gather the 3 datoms results. But I would imagine that would take a few microseconds to complete.

I am currently designing a front-end app that will contain a lot of entities (in the 10000s). From what I understand, it would be unusable with Datascript because reaction times would be in the 100s of milliseconds.

Am I missing something?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with benchmark query q4 and the reported 20,000-entity JVM comparison; no source files or tests are named in the issue. Determine why the Datascript query takes about 40 milliseconds, compare the JVM and CLJS behavior, and document whether the observed performance is expected or requires a change.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
databases, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.