Equivalent of SQL "limit" clause in Datomic
clojure, datomic
Solution
Two random names using rand (duplicates tolerated) and sample (only distinct)
(d/q '[:find [(rand 2 ?name) (sample 2 ?name)]
:where [_ :artist/name ?name]]
db)
This example came from the day-of-datomic github repo.
Problem
Title sort of says it all, but say I have a simple query as follows: ``` (q '[:find ?c ?n :where [?c :my-thing/its-attribute ?n]] (d/db conn)) ``` against a schema like ``` [{:db/id (d/tempid :db.part/db) :db/ident :my-thing/its-attribute :db/valueType :db.type/string :db/doc "My thing's attribute" :db/cardinality :db.cardinality/one :db.install/_attribute :db.part/db}] ``` If the query matches everything (say, 100M entries), the returned results will be large. If I just want a few of them, what's the best way to do that?