Fork me on GitHub

is d/transact-async bound by datomic.txTimeoutMsec as d/transact is?


transact-async has no timeout.


np 🙂


Hi! Quick question on datomic data modelling: how would you store a large sequence of items (e.g. a news feed) in such a way that the N latest items can be retrieved efficiently?


@hmaurer - I think this kind of thing might not be easy in Datomic. (I hope somebody more knowledgeable about Datomic corrects me though.)


Or, wait…unless you mean the N most-recently-transacted items. In which case maybe the Log API would be what you need?


Disclaimer: speaking from semi-ignorance here…


@jeff.terrell haha no problem, that’s what I do most of the time. The N most-recently transacted items could work but I was looking for a more general solution. From what I understand about Datomic I think you are right though, it might not be possible without building an additional service…


One possibility would be to subscribe to the stream of transactions (I think this is possible in Datomic), then maintain a data structure with the information you need.


@hmaurer @jeff.terrell the disadvantage with walking the log backwards is you have to keep reading chunks of N txes until you’ve filled however many items you need. in a database with lots of other stuff, this could mean traversing a lot of non-news-item txes. you could use the linked-list approach, where the latest item points to the next-latest item which points to the next-next-latest item which …, which then gives you a pretty straightforward path to discovery.


robert-stuttaford: Ah, yeah…that's familiar, now that you say it. Thanks for clarifying that. simple_smile


i believe Datomic’s feature request thing has a request for traversing indexes in reverse, which would give you a very clear and direct path: traverse the “primary key” attribute in reverse.


Here's a link to that feature request (might have to log in through first, I dunno):


@robert-stuttaford hi and thank you! Is there an efficient Datalog query to get the top N items from a linked list?


@robert-stuttaford Also, is there a way for a service to follow the transaction log while ensuring that it doesn’t “miss” any transaction? You mentioned using Onyx so you might know about this