Currently your driver when enlisting in TransactionScope always do two phase commit, even when it is the only participant of transaction, PREPARE TRANSACTION; COMMIT PREPARED is executed on successful transaction end.
I did some benchmarks, and using TransactionScope is 2-2.5 times slower then using Connection.BeginTransaction() due to always doing 2PC with PREPARE TRANSACTION.
I guess your are always enlisting with Transaction.EnlistVolatile(IEnlistmentNotification) which will always call prepare then commit, when you could do Transaction.EnlistVolatile(ISinglePhaseNotification) or EnlistPromotableSinglePhase
Code: Select all
[TestMethod]
public void TX()
{
using (TransactionScope ts = new TransactionScope())
{
PgSqlConnection connection = new PgSqlConnection("...;Enlist=true;Unicode=true");
connection.Open();
ts.Complete();
}
}