Fork me on GitHub
#xtdb
<
2022-02-04
>
Brandon Olivier22:02:04

Is there a way to order-by transaction time?

alexdavis01:02:19

You can use the entity-history function (and write a helper function to assoc tx/valid time into the entity for sorting) but there's no way (yet) to get that information just from a query

refset14:02:44

You can however embed those entity-history functions inside a query (which is reasonably efficient) see https://gist.github.com/refset/8439ceebf3c1f08c614b0c818266a140 (and then apply a Datalog order-by - which in turn may not be that efficient, depending on the size of the result set)

Brandon Olivier22:02:14

Or would I need to add a new field to my document for that?

refset14:02:07

This is generally the better option if you require access to the data for fast & flexible querying (in the current version of XT, at least 🙂)

👍 1