Speeding up OpenCMS : Moving auto-commit logic from Jaybird to the Firebird
Smyatkin Maxim from RedSoft proposed the following changes in this pull request for Jaybird :
Jaybird shows horrible performance in auto-commit mode while executing
lots of small queries.
Reasons:
1. Every time a statement is being executed a new transaction starts and
commits.
2. Even if there were no changes at all (e.g., simple select statement)
Jaybird starts and commits transaction.
Solution: Firebird API has its own auto-commit flag. Firebird knows for
sure if anything did actually change, so Jaybird might rely on it. As a
result:
1. It saves start and commit calls;
2. It executes commits only if something really changed;
3. Internally it works faster even if changes appeared because it doesn’t
restart a transaction.
Practical results: it allowed me to make OpenCMS work 3-5 times faster
with Firebird. I suppose it’s not the only case, because some systems
(especially the ones using ORMs) tend to execute lots of small selects.
Main changes in code are:
1. Removed AutocommitTransactionCoordinator. LocalTransactionCoordinator
with enabled autoCommit flag does exactly what we need.
2. When we change autoCoommit to true/false – we commit previous
transaction manually, so that it restarts with new TPB.