Subject Re: [firebird-support] Tx Handling when Reading Info from DB
Author Aage Johansen
Larry Hengen wrote:
> In our application in one operation, we perform a couple updates,
> followed by a series of queries to gather information. Due to the fact
> we perform updates the Tx parameters are set for Read/Write.
>
> I have a couple of questions concerning this usage of queries:
>
> 1) Should I change the Tx parameters to be Readonly after we have done
> the updates?
>
> 2) is it more efficient to do all the reads in 1 Tx issuing a
> RollbackRetaining after each query, or start a new Tx, open a query and
> rollback the Tx, then do it all over again for the next read?
>
> 3)Is there anyway to get Tx timings from the Firebird engine itself so
> you can monitor for long running Txs?
>

If I understand your situation correctly, I would either:
1) If you want the updates to stay:
a) Run the updates, commit; Run the rest in a readonly
transaction; commit.
or
b) Run everything in one transaction, then commit.
or
2) If you want to rollback the updates:
Run everything in one transaction, then rollback.

If the complete operation is "short", I would just do all it in one
transaction.
As for efficiency, I don't think you will notice any dofference.

Don't use RollbackRetaining/CommitRetaining if it can be avoided.
(Unless you also do a proper Rollback/Commit whenever appropriate)


--
Aage J.