Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf improvement: BeginReadTransaction will not use transactions #106

Closed
PaulStovell opened this issue May 8, 2020 · 0 comments
Closed

Comments

@PaulStovell
Copy link
Member

PaulStovell commented May 8, 2020

The "unit of work" in Nevermore was always a "transaction":

using var transaction = store.BeginTransaction();
var person = transaction.Load<Person>("Persons-1");
person.Name = "Fred";
transaction.Update(person);
transaction.Commit();

Since any unit of work may change data, it made sense to always create a transaction. This means every unit of work would open a connection, then call SqlConnection.BeginTransaction.

Nevermore 12 introduced BeginReadTransaction, which can be used to read data but has no methods for changing it. This was mostly intended for geo-replication scenarios where you are reading from a read-only replica, and want to avoid programming errors.

using var transaction = store.BeginReadTransaction();
var people = transaction.Query<Person>().ToList();

However, it still called BeginTransaction with read-committed isolation level for every call. And since we are by definition only reading data, this isn't necessary.

In Nevermore 12.7 the behavior will change so that BeginReadTransaction no longer calls BeginTransaction - it simply opens the SQL connection without creating a transaction. This shaves some time off the query:

image

The slightly confusing part is that BeginReadTransaction doesn't actually begin a transaction anymore 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant