clojuredatomic

Slow query using `pull` (datahike) to retrieve attributes on 400 entities


I am using Datahike 0.6.1531 (not Datomic) on the JVM. I have a list of book titles to display in a web app. If the book is "notable", I do something special, like apply a background-color or append an emoji to it.

I would like to return a vector that resembles something like this:

[{:db/id 339, :resource-name "Notation as a Tool of Thought"}
 {:db/id 338, :resource-name "The Science of Radio", :notable? :true}
 {:db/id 337, :resource-name "Journey Into Mathematics"}
 {:db/id 336, :resource-name "Street Fighting Mathematics"}
 ...]

Performing the following pull-many query with 3 attr-ids (including :db/id) on a range of 400 or so entities requires ~2,900 ms:

(require '[datahike.api :as d]) ; version 0.6.1531
(d/pull-many @conn [:db/id :resource-name :notable?] 
  (range 1 400))

Is the slow query time an inherent trade-off of EAV databases, or am I failing to optimize in some very obvious way?


Solution

  • This issue was addressed and solved by Datahike maintainers in this pull request: https://github.com/replikativ/datahike/pull/653