datomic

braai engineer 2025-06-10T08:40:26.581479Z

Why am I getting output from d/datoms for a tuple attribute, but no results when using d/index-range on the tuple, when using in-memory On Prem? I'm passing values that I know exist based on d/datoms:

(into [] (d/datoms db :avet :eacl.permission/resource-type+permission-name))
=> [#datom[17592186045426 96 [:account :admin] 13194139534313 true]
 #datom[17592186045427 96 [:account :view] 13194139534313 true]
 ...] 

(into [] (d/index-range db :eacl.permission/resource-type+permission-name [:account :admin] [:account :admin]))
=> []
(the tuple contains keywords, not eids)

braai engineer 2025-06-10T08:47:20.688259Z

Ah, I see that end is exclusive. I'm getting output for this:

(into [] (d/index-range db :eacl.permission/resource-type+permission-name [:account :admin] nil)) => results
where end is nil, or
(into [] (d/index-range db :eacl.permission/resource-type+permission-name [:account :admin] [:server nil])) => results
But if there's only one result starting with :account, I'm not sure how to query that without fetching everything, e.g. this is empty:
(into [] (d/index-range db :eacl.permission/resource-type+permission-name [:account :admin] [:account nil])) => []
How to use index-range if there's only one value for the starting key?

braai engineer 2025-06-10T08:48:05.860309Z

Surprised I can't do this:

(into [] (d/index-range db :eacl.permission/resource-type+permission-name [:account :admin] [nil nil]))
(get an empty result set)

favila 2025-06-10T12:42:03.091969Z

Just take-while

favila 2025-06-10T19:10:20.621699Z

reason nil doesn't work as an end is it sorts lower than any other value. It's not understood as a "no limit" sentinel unless the entire end argument is nil

favila 2025-06-10T19:12:37.013119Z

(sequence
 (take-while (fn [datom] (= [:account :admin] (:v datom))))
 (d/index-range db :eacl.permission/resource-type+permission-name [:account :admin] nil)
 )
example of take-while

πŸ‘ 1
favila 2025-06-10T19:13:06.140019Z

d/datom would work fine for this simple case also

favila 2025-06-10T19:13:26.034489Z

(d/datoms db :avet :eacl.permission/resource-type+permission-name [:account :admin])

braai engineer 2025-06-10T19:14:10.135279Z

benchmarked d/datoms vs d/seek-datoms and was surprised that d/datoms was ~10x faster via criterium (we’re talking nano & milliseconds here)

favila 2025-06-10T19:16:28.610199Z

seek-datoms?

favila 2025-06-10T19:16:39.623009Z

were you comparing equivalent things?

braai engineer 2025-06-10T19:19:20.778259Z

this was the last benchmark I ran:

(quick-bench
  (first (d/datoms (d/db conn) :avet :eacl.relationship/subject+relation-name+resource
    [(:db/id super-user) :super_admin (:db/id platform)])))
vs.:
(quick-bench
    (first (d/seek-datoms (d/db conn) :avet :eacl.relationship/subject+relation-name+resource
    [(:db/id super-user) :super_admin (:db/id platform)])))
so either I'm misunderstanding how it works, or d/seek-datoms is chunking

favila 2025-06-10T19:19:49.258959Z

seek-datoms does not terminate

πŸ‘ 1
braai engineer 2025-06-10T19:19:56.048459Z

ahh

favila 2025-06-10T19:20:07.469339Z

there's no guarantee that first item matches your parameters

favila 2025-06-10T19:20:24.005749Z

this is also mostly measuring setup costs, not the cost of scanning

favila 2025-06-10T19:22:10.532909Z

docstring for seek-datoms: https://docs.datomic.com/clojure/index.html#datomic.api/seek-datoms

vc 2025-06-10T18:29:49.294579Z

what is the standard practice to enforce right-to-be-forgotten in datomic?

favila 2025-06-10T19:08:22.616829Z

there are two:

favila 2025-06-10T19:08:36.529939Z

1. use excision (datomic pro only)

❀️ 1
favila 2025-06-10T19:09:09.309679Z

2. use a supplemental storage for PII that supports delete, store a pointer in datomic.

vc 2025-06-10T20:00:50.457259Z

Thanks. Had no idea excision was there. Didn't come across in docs neither (as usual) gpt revealed it.

Sven 2025-06-10T20:30:47.650059Z

> 1. use excision (datomic pro only) Any plans of supporting it in Cloud?

favila 2025-06-10T20:31:29.595409Z

not ruled out, but no concrete plans to add right now

😒 2
βœ… 1