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

Improve DB connection efficiency #21

Open
mcshaz opened this issue Dec 21, 2020 · 0 comments
Open

Improve DB connection efficiency #21

mcshaz opened this issue Dec 21, 2020 · 0 comments

Comments

@mcshaz
Copy link

mcshaz commented Dec 21, 2020

At the moment each of the 8 classes inheriting from IdentityTable create their own open connection to the DB at instantiation, all of which will only be closed when the scoped instance is disposed. This seems inefficient. I am a long way from an expert on the topic, but I wonder whether a more efficient method of doing this could be created by using any/all of:

  1. Have the scoped IDbConnectionFactory return a single instance rather than create a new connection every time. Have the IDbConnectionFactory - now really an IdbConnectionStore implement IDisposable instead of the IdentityTables, and rather than create have a getOrCreate property.
  2. Only access the connection in the IdentityTable instances when required, rather than at instantiation
  3. Do not open the connection manually - as I understand if the connection is not open Dapper will open and close it automatically when one of the execute or query methods is called. It may however be more efficient to leave the connection open - I am unsure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant