Databases Reference
In-Depth Information
For more information about how garbage collection works in the Common
Language Runtime (CLR), see “.NET CLR,” page 82.
Obtaining Database and Data Provider Information Efficiently
Remember that creating a connection is one of the most performance-expensive
operations that an application performs.
Performance Tip
Because of the performance hit your application pays for opening con-
nections, avoid establishing additional connections to gather information
about the data provider and the database, such as supported data types
or database versions. For example, some applications establish a connec-
tion and then call a method in a separate component that reconnects and
gathers information about the data provider and the database. Use the
DbMetaDataCollectionNames.DataSourceInformation field of the
GetSchema method to share metadata.
How often do databases change their supported data types or database ver-
sions between connections? Because this type of information typically doesn't
change between connections and isn't a large amount of information to store,
you may want to retrieve and cache the information so the application can access
it later.
Managing Transactions
To ensure data integrity, all statements in a transaction are committed or rolled
back as a unit. For example, when you use a computer to transfer money from
one bank account to another, the request involves a transaction—updating val-
ues stored in the database for both accounts. If all parts of that unit of work suc-
ceed, the transaction is committed. If any part of that unit of work fails, the
transaction is rolled back.
Use the guidelines in this section to manage transactions more efficiently.
Managing Commits in Transactions
Committing (and rolling back) transactions is slow because of the disk I/O and,
potentially, the number of network round trips required. What does a commit
 
 
 
Search WWH ::




Custom Search