Fork me on GitHub

Querying “entity with greatest some-attr and pulling from that”, I’ve been using not-join to query that there isn’t another entity with a greater value and was wondering if there is a more convenient pattern I’m missing?

Lennart Buit07:04:15

{:find [(max ?some-attr) (pull ?e [*])] …} perhaps, or am I now missing something


that returns multiple result rows… each the max and each ?e


I only care about the ?e with the max value and want to pull from that, so result should have single row


I just figured, that instead of not-join I can bind the (max ?some-attr) to value and find the ?ebased on (as the values in my case are unique) EDIT: scratch that, gives different result


split it into two queries: first find the single max value for attr, then query the entity based on that max value… that was faster than not-join

Joe Lane13:04:16

Hey @U11SJ6Q0K , can you create a minimal repro of the data , schema, and the desired result using dev-local ? I’m interested in documenting optimal solutions to this but I think it will depend on quantity, use of tuples, insert/update patterns, etc :)


not sure if I have enough cases for a general case. Looks to me that it’s just about how complex the query to get the “max of some attr” is and how then can you get the :db/id of the entity that had the max value


a max-with-id aggregate that returns the max value and the :db/id of the entity that had it, feels like would be useful

Joe Lane13:04:47

Is this all that you’re doing with the query? could you use index-pull or index-range and just grab the first element? Could you write a query function to do that for you from within the query ( if you need to pass that value to other where clauses, for example) Use Reverse flag for max (I think, on mobile).


Hey team, noob question, I wanted to make sure I understood. For the starter plan, What does 1 year of updates / maintenance mean? i.e what will happen after 1 year? Would I simply get another starter license, and upgrade, or something else? Looking at this description, it seems like the difference between starter and pro is support + updates. I wanted to make sure I fully understood that this is the only difference (i.e I can have multiple boxes of datomic running, etc)