Hi Thomas,
Re 1: this is a matter of whether you need ACID behavior for all operations
or not. If all operations must be executed as one atomic transaction, then
you do not have a choice and must put them into a single transaction. If
you only some of the operations need to be run together as an atomic batch,
and it is no problem if other operations interfere after them but before
starting the next sub transaction, then it is ok the split a big
transaction into multiple smaller ones. But if later operations in the big
transaction rely on earlier operations in the same transaction, then
splitting the big transaction into smaller sub parts may produce different
results than running everything in one transaction.
The locking problem will by the way be addressed in the 3.2 because we'll
be adding an alternative storage engine with document-level locking there.
Re 2: when passing variables from one transaction into another, both
variants will work when they are executed inside arangod. It is then only a
matter of personal preference which variant to use.
However, the code will be more portable when using the explicit variant
(the one that uses "params"). The params variant should work from the
ArangoShell (arangosh) as well, because the "myVar" parameter value will be
serialized and sent to the server. The variant that uses the local variable
will fail when executed from ArangoShell, because the transaction will be
executed on the server, which will have no idea of "myVar".
In general, it is recommended to define or require all variables in a
transaction that are needed by it, and to not rely on external data from
outside the transaction except data passed into it via params.
Best regards
Jan
Am Dienstag, 25. April 2017 06:25:03 UTC+2 schrieb Thomas Weiss:
>
> Hi everyone,
>
> I'm using cross-collection transactions a lot and, as ArangoDB's locking
> model is at the collection level and not the document, I'm thinking about
> how scalable this is when you have a lot of writes coming in.
>
> So I was wondering:
> 1. Is it better to group all operations in a single transaction or when
> possible, break them down into several smaller transactions spanning less
> collections (all called sequentially within the same Foxx route)?
>
> 2. When chaining transactions, sometimes I have to pass data from one to
> the other; in that case, is it better to
> a. use variables with a scope that spans all transactions:
> var myVar;
> db._executeTransaction({
> // set myVar
> })
> db._executeTransaction({
> // use myVar
> })
> b. pass those variables in and out of the transactions:
> var myVar = db._executeTransaction({
> })
> db._executeTransaction({
> params: myVar
> })
>
> Thanks!
> Thomas
>
--
You received this message because you are subscribed to the Google Groups
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.