Reputation: 10995
I've been wondering if it is efficient to save a database instance per user to prevent creating an instance whenever the user reconnects. For example a user wants to use a search mechanism, so he sends a request to the server, which creates a new database per request. But is there a way to save it just once until the user decides to quit by closing the tab or browser... It sounds session specific, but it appears using session might be a bad idea. I thought some would have asked this before, but couldn't find an answer. So should I leave it as it is, save the instance (or does the server do that for me anyways).. or should I manually do it myself? And how should I do it?
Upvotes: 0
Views: 297
Reputation: 101166
Leave it as it is. Most (if not all) ADO.NET drivers uses connection pooling. It means that the connections aren't really closed when you invoke Connection.Close()
. They are just returned to the pool.
Upvotes: 2