datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
2020-09-28T06:38:25.061800Z

Is it possible to find the entity with the maximum of some attribute in datalog?

Yuriy Zaytsev 2020-09-28T08:37:40.061900Z

(d\q '{:find [(max ?attr)] :in [$] :where [[_ :some/attribute ?attr]]} db)

2020-09-28T15:58:37.064700Z

How do you get the entitie whose attribute is the maximum?

Yuriy Zaytsev 2020-09-28T16:08:22.064900Z

(d/q '{:find  [?entity]
         :in    [$]
         :where [[(datomic.client.api/q '{:find [(max ?attr)]
                                         :in [$]
                                         :where [[?entity :some/attribute ?attr]]} $) [[?attr]]]
                                         [?entity :user-metric/elapsed-ms ?attr]]} db)
  

2020-09-28T16:42:50.065500Z

So nested queries?

Yuriy Zaytsev 2020-09-28T16:43:29.065700Z

yes

Yuriy Zaytsev 2020-09-28T08:37:40.061900Z

(d\q '{:find [(max ?attr)] :in [$] :where [[_ :some/attribute ?attr]]} db)

2020-09-28T15:58:37.064700Z

How do you get the entitie whose attribute is the maximum?

Yuriy Zaytsev 2020-09-28T16:08:22.064900Z

(d/q '{:find  [?entity]
         :in    [$]
         :where [[(datomic.client.api/q '{:find [(max ?attr)]
                                         :in [$]
                                         :where [[?entity :some/attribute ?attr]]} $) [[?attr]]]
                                         [?entity :user-metric/elapsed-ms ?attr]]} db)
  

2020-09-28T16:42:50.065500Z

So nested queries?

Yuriy Zaytsev 2020-09-28T16:43:29.065700Z

yes

steveb8n 2020-09-28T22:20:53.067200Z

Q: I have a very slow memory leak in a production Cloud system. Before I start dumping logs and digging around, I wonder if folks out there have any tricks/tips for this process. I’ll post the chart in the thread…..

jaret 2020-09-29T12:15:36.097100Z

Hi @steveb8n, have you actually seen a node go OOM or are you just noticing this in your metrics/dashboard? This small snippet matches with the expectations I have for indexing. The indexing job occurs in the background. Indexing is done in memory and then the in-memory index is merged with the persistent index and a new persistent index is written to the storage service. If you widen the time scale you should see a saw tooth pattern on your indexing line.

steveb8n 2020-09-29T22:20:26.137300Z

@jaret No I haven’t yet in prod but the same code running on Solo (test system) has gone OOM. That chart is 2 weeks, hence no saw tooth. Here’s the hour just gone. Saw tooth as expected

steveb8n 2020-09-29T22:21:40.137700Z

Interesting that you think this is normal. Is there some doc somewhere that describes what “normal” is for charts in the dashboard? That would help me (and others I suspect)

steveb8n 2020-09-29T22:22:23.137900Z

Whenever I deploy new code, the FreeMem line jumps back up to 10Mb and starts the slow decline

steveb8n 2020-09-28T22:22:00.067800Z

steveb8n 2020-09-28T22:22:32.068200Z

In particular, I wonder why the indexer line goes up. And does that provide a clue about the leak?