This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-26
Channels
- # announcements (18)
- # aws (17)
- # babashka (19)
- # beginners (141)
- # calva (73)
- # cider (4)
- # clj-kondo (13)
- # cljs-dev (2)
- # clojure (97)
- # clojure-europe (6)
- # clojure-italy (5)
- # clojure-nl (1)
- # clojure-spec (25)
- # clojure-sweden (2)
- # clojure-uk (25)
- # clojured (3)
- # clojurescript (63)
- # core-typed (6)
- # cursive (23)
- # data-science (4)
- # datomic (74)
- # fulcro (19)
- # graalvm (18)
- # graphql (3)
- # hoplon (63)
- # jackdaw (1)
- # juxt (23)
- # london-clojurians (3)
- # meander (7)
- # off-topic (23)
- # om (1)
- # pathom (13)
- # pedestal (2)
- # perun (2)
- # re-frame (38)
- # reagent (3)
- # reitit (24)
- # shadow-cljs (91)
- # spacemacs (14)
- # sql (4)
- # tools-deps (8)
- # vim (3)
one can (and should) split stacks in a solo cloud install, correct? And recreate the storage stack and solo compute stack?
Hi. I use datomic on-prem (via the Peer API) with a number of Datomic installations (think production, staging etc) In most of them everything is OK, but for one of them, query latency is consistently high; 1500ms, for the simplest, cheapest possible query. Indices are in place. We also tried to rule out basic stuff (configuration/environment differences, etc) What are some possible causes, or things we can do to troubleshoot this?
In case it helps: how come the latency is slow every time? Given the Datomic architecture (AIUI), queries should be in-memory, with updates being pushed over the wire. So after a slow first query, subsequent queries should be fast... but nope.
We haven't noticed any significant difference - DB size, indices, infrastructure details
maybe in staging you have only 1 peer but in production you have multiple peers and 1 of the peers has high latency?
I noticed in on-prem there is an optional :db/index
attribute (https://docs.datomic.com/on-prem/schema.html#operational-schema-attributes) but I don't see one in the cloud docs. Are all attributes indexed in cloud?
I don't see it exlicitly stated in the docs, just alluded to here: "Datomic datalog queries automatically use multiple indexes to support a variety of access patterns" (https://docs.datomic.com/cloud/whatis/data-model.html) The differences page, doesn't mention it other than the full-text difference: https://docs.datomic.com/on-prem/moving-to-cloud.html#text-search
Are lookup refs not valid values for transactions for ref attributes in cloud? As per https://blog.datomic.com/2014/02/datomic-lookup-refs.html Similarly, they can be used in transactions to build ref relationships.
but I get “entity not resolved” with the full tuple as an error in cloud
(d/with with-db {:tx-data [{:space/uuid #uuid "some-space-uuid"
:space/devices [:device/id "some-device-id"]}]})
:space/devices
is cardinality many, type ref. I realized the issue with this version is the cardinality many means that the vector is interpreted as a vector of refs, so i’m actually pointing to the ident :device/id
and an unknown tempid.
I then tried another version:
(d/with with-db {:tx-data [{:space/uuid #uuid "some-space-uuid"
:space/devices [[:device/id "some-device-id"]]}]})
And this time after querying the database and looking at the committed transactions it seemed like nothing changed. Solved this issue just splitting the reference into temp ids as mentioned (coincidentally) in the latest conversation here, but was just wondering if it’s possible to use lookup refs as the value in ref type attributes.:space/uuid is identity, type uuid :space/devices is type ref, cardinality many No error on the second one, just nothing updated (looking at the after-db, the intended space->device datom was not found)
First one errored
tempid 'd5f2962bd37b24c1c7cb076b9053ae77' used only as value in transaction
which made sense per above reasoning, I then added another pair of square brackets to intend it as a lookup ref#:db{:ident :space/devices,
:valueType :db.type/ref,
:cardinality :db.cardinality/many}
#:db{:ident :space/uuid,
:valueType :db.type/uuid,
:cardinality :db.cardinality/one,
:unique :db.unique/identity}
Turns out another false alarm, thanks for your time! Am I correct to assume that datomic will automatically infer the meaning of a vector based on both schema ident cardinality and type? Got a little confused from how overloaded the square brackets were
@eagonmeng what version of cloud?
@U05120CBV Hmm, was there a rollback for the released version of cloud? I’m on DatomicCFTVersion 616
, which I believe was just released recently on 2/21 (https://webcache.googleusercontent.com/search?q=cache:cWl9SuBuZeMJ:https://docs.datomic.com/cloud/releases.html+&cd=1&hl=en&ct=clnk&gl=us) but it’s mysteriously disappeared off the main page (https://docs.datomic.com/cloud/releases.html)
note: https://docs.datomic.com/cloud/releases.html#569-8835 • (Fix: resolve tempids for reference attributes inside tuples.)
however, you should move to the latest; it includes a fix for a different regression in that version
I need to write to several different "schemas" in a single Datomic transaction, e.g., phone numbers, emails accounts, person information and address information. All of these write create eids which are then stored in a customer. I need to do this atomically, but I cannot figure out how to recover eids from within a transaction function. Any ideas?
@hadilsabbagh18 Do you need a transaction function, or can you use tempids (https://docs.datomic.com/cloud/transactions/transaction-processing.html#tempid-resolution)?
transaction functions (the ones that run inside datomic) return transaction data, which is later committed
@ghaid @shaun-mahood Understood. How do I create such a transaction atomically?
if you need to transact something compound in the same Datomic transaction, you just give it to transact:
(d/transact conn {:tx-data [thing1 ... thing2.... thing3]})
transaction functions are something different and should be used to achieve specific purposes (they're like macros that run while the tx is being committed)
Thanks @ghadi. I have a one->many relationship between phone numbers and persons. How would I do that in a single transaction?
I've got an example I can paste in here - will redact it quickly and throw it in a thread (the docs are great, but I sometimes need a few extra examples to figure things out the first time)
(d/transact conn {:tx-data
[[:db/add "request" :request/date request-date]
[:db/add "client" :client/name client-name]
[:db/add "job" :job/name job-name]
[:db/add "job" :job/client "client"]
[:db/add "job" :job/request "request"]]})
@shaun-mahood you can email it to me at <mailto:[email protected]|[email protected]>
https://docs.datomic.com/cloud/transactions/transaction-processing.html#tempid-resolution
@ghadi. The problem is that i need to commit data atomically, not how to retrieve tempids.
[{:db/id "customer1"
:customer/name "hadils"}
{:db/id "customer2"
:customer/name "ghadi"
:friends/with "customer1"}]
in that example, two new entities are created, and the second entity points to the first entity
two tempids "customer1" "customer2" will be resolved into two entity-ids when committed
@ghadi. I am with you. So I need to not use tempids then, I need some other reference for a one-many relationship.
if you have a unique ID you can send that in instead of the tempid -- but the end result is the same: datomic needs to know what entities you're asserting things about
I think my biggest stumbling blocks in learning Datomic have all been related to how simple it is at the core