datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
tatut 2021-04-22T04:52:56.356300Z

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?

2021-04-22T07:23:15.356400Z

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

tatut 2021-04-22T07:34:11.356600Z

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

tatut 2021-04-22T08:02:40.356800Z

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

tatut 2021-04-22T08:03:42.357Z

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

tatut 2021-04-22T08:30:48.357300Z

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 Lane 2021-04-22T13:08:16.361100Z

Hey @tatut , 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 :)

tatut 2021-04-23T04:02:17.363700Z

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

tatut 2021-04-23T04:10:28.363900Z

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 Lane 2021-04-23T13:47:47.371500Z

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).

2021-04-22T07:23:15.356400Z

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

tatut 2021-04-22T07:34:11.356600Z

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

tatut 2021-04-22T08:02:40.356800Z

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

tatut 2021-04-22T08:03:42.357Z

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

tatut 2021-04-22T08:30:48.357300Z

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 Lane 2021-04-22T13:08:16.361100Z

Hey @tatut , 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 :)

2021-04-22T18:32:06.363200Z

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)