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

SQL Server: Possible perf optimization leveraging autocommit transactions in SaveChanges() #6342

Closed
divega opened this issue Aug 17, 2016 · 5 comments

Comments

@divega
Copy link
Contributor

divega commented Aug 17, 2016

By default every Transact-SQL statements is executed in autocommit mode, meaning that it will be automatically committed if it succeeds and rolled back if it fails. In theory when SaveChanges() gets invoked with only one changed object which doesn't have database generated values, we shouldn't need to wrap the statement in a transaction.

@divega divega changed the title SQL Server: Possible perf optimization leveraging autocommit transactions in SaveChanges() SQL Server: Possible perf optimization leveraging autocommit transactions in SaveChanges() Aug 17, 2016
@gdoron
Copy link

gdoron commented Aug 17, 2016

Nice idea.
I guess it would be an opt-in feature since you don't really know whether the DB default transactions mode has been changed.
Right

@divega
Copy link
Contributor Author

divega commented Aug 17, 2016

Triage: we want to understand the actual benefit of this before we prioritize it.

@divega
Copy link
Contributor Author

divega commented Aug 17, 2016

I guess it would be an opt-in feature since you don't really know whether the DB default transactions mode has been changed.

@gdoron are you talking about SET IMPLICIT_TRANSACTIONS ON or is there any other way to affect the default transaction mode? We should try it but incidentally I believe things would work similarly for most cases as long as the DbContext controls connection opening and closing (maybe we only apply the optimization if that is the case).

@AndriySvyryd
Copy link
Member

There was no measurable difference, SQL Client probably already optimizes this

@divega
Copy link
Contributor Author

divega commented Aug 19, 2016

@AndriySvyryd thanks for the prompt investigation. Closing.

@divega divega closed this as completed Aug 19, 2016
@AndriySvyryd AndriySvyryd removed their assignment Apr 21, 2017
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
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

4 participants