Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Optimize Database Connectivity
in .NET Applications
March 17, 2016
Avadhoot Kulkarni
© 2013 Progress Software Corporation. All rights reserved.2
INTRODUCTION
Avadhoot Kulkarni
Product Owner ODBC, JDBC & ADO.NET Drivers, Progress DataDirect
https://www.progress.com/net
Avadhoot.Kulkarni@progress.com
© 2013 Progress Software Corporation. All rights reserved.3
AGENDA
Components of Performance
Performance Strategy
ADO.NET Data Provider
 Architecture of Data Provider
 Connection Improvements
 Query Execution Improvement
 Result Fetching Improvements
 Coding Guidelines
© 2013 Progress Software Corporation. All rights reserved.4
Components of Performance
Database Network Data Provider
Data Access
Code
Client
Infrastructure
© 2013 Progress Software Corporation. All rights reserved.5
Do not fix your applications for better performance,
Design it to perform better.
PERFORMANCE STRATEGY
© 2013 Progress Software Corporation. All rights reserved.6
Architecture
© 2013 Progress Software Corporation. All rights reserved.7
Architecture of Data Provider
 Architecture
• Managed vs. Unmanaged
• How well you manage the resources
– Database Capabilities
– Network Bandwidth
– Disk I/O
– CPU
– Memory
© 2013 Progress Software Corporation. All rights reserved.8
Connection
Improvements
© 2013 Progress Software Corporation. All rights reserved.9
Connection Improvements
 Avoid XA (Distributed Transaction) Enabled Connections (Enlist)
 Use Connection Pooling
• Benefit
• Pooling strategies
• When to avoid
 Use Bigger Protocol Packet Sizes
 Avoid Distributed Transactions
 Choose Extended Security Wisely
© 2013 Progress Software Corporation. All rights reserved.10
Use Connection Pooling
1. Application Server Started;
Connection Pool is populated
2. Application Makes a Connection
Request
3. A pooled Connection is given to
application.
4. Application is Connected to
database.
5. When the connection is closed, it
is placed back into the pool.
Application Server
Application
© 2013 Progress Software Corporation. All rights reserved.11
When to avoid Connection Pooling
 Frequently Restarting Applications
They pay upfront cost of populating the pool and hold up resources, which all gets lost
when application restarts.
 Single User Applications (e.g. Report Writers)
If the application needs to establish connection to database once in a while, for single
use, resources held by pool hamper the performance more than the pooling could
help.
 Single User Batch Jobs
Pooling offers no advantage to such applications, as they just need one connection.
Especially as these batch jobs are executed off ours when there is no real load on
server.
© 2013 Progress Software Corporation. All rights reserved.12
Use Bigger Protocol Packet Size
 Communication packet size is limited to Servers max packet size limit.
 Typically, larger the packet size, the better the performance
© 2013 Progress Software Corporation. All rights reserved.13
Avoid Distributed Transactions
 Distributed Transactions are used to execute atomic operations across multiple
connections. These are needed to keep data consistent.
 Requires communication between multiple servers, Hence are very slow compared
to local transactions.
 This co-ordination could be between several types of database servers e.g. SQL
Server, Oracle, DB2, Sybase, MySQL etc. or, multiple instances of same database
types.
 Be very cautious while designing applications; multiple databases architecture
would most likely require distributed transactions.
© 2013 Progress Software Corporation. All rights reserved.14
Choose Extended Security Wisely
 Performance Penalties are side effects of extended security. Let’s see if its possible
to limit them…
 There are 2 types to the extended security
• Network Authentications
• Data Encryption over Network
© 2013 Progress Software Corporation. All rights reserved.15
Improve Kerberos Authentication Performance
 Bottle Neck: As for each connection, client need to get a ticket from Kerberos server,
it can quickly become a bottle neck if it’s a shared server with lots of network heavy
services running on it.
 Place Kerberos Server on Dedicated machine
 Reduce Networking services run on this machine to bare minimum
 Make sure you have fast, reliable network connection to the machine
© 2013 Progress Software Corporation. All rights reserved.16
Avoid Unnecessary Data Encryption
 For secure transition of data another layer is added over TCP/IP i.e. SSL or any
proprietary Encryption of database vendor.
 Performance Intensive steps
• Initial Handshake
• Encryption and Decryption
 Usually longer the Cipher Key means more the security but lesser the performance.
 Use encrypted connections for sensitive data and unencrypted for non-sensitive data.
Though, not all databases supports this functionality.
© 2013 Progress Software Corporation. All rights reserved.17
Query Execution
Improvement
© 2013 Progress Software Corporation. All rights reserved.18
Query Execution Improvements
 Use Transactions (Auto-Commit)
 Use Prepared Queries
 Use Statement Caching/Pooling
 Use Parameterized Batching
 Use Bulk Protocols
© 2013 Progress Software Corporation. All rights reserved.19
Use Transactions (Auto-Commit=FALSE)
 In ADO.NET Default Auto Commit Mode is TRUE.
 DB2 do not support Auto-Commit mode, Data Provider by default send commit request
after every successful operation.
 Application has no control on when the Commit is fired. Mostly it gets fired even when
there is nothing to commit.
 Every commit and Rollback operation is performance Intensive
• Requires Disk I/O and sometimes network roundtrips.
Cont.…
© 2013 Progress Software Corporation. All rights reserved.20
Use Transactions (Auto-Commit=FALSE)
 In most cases you will want to turn off Auto-Commit mode. Start BeginTransaction()
to start local transaction in your application.
 Leaving transactions active can reduce throughput by holding locks for longer than
necessary.
Committing transactions in intervals gives best
performance with acceptable concurrency.
© 2013 Progress Software Corporation. All rights reserved.21
Use Prepared Queries
 Calling Command.Prepare() usually compiles the SQL statement into query plan for
efficiency.
 Available until the connection is closed.
 Though initial execution overhead of prepare is high, advantage is realised in
subsequent executions.
 Some databases like DB2 and Oracle supports Prepare and execute together, which has
multiple benefits.
© 2013 Progress Software Corporation. All rights reserved.22
Use Statement Caching/Pooling
 Statement Pool is group of prepared statements that an application can reuse.
 Its not a feature of database systems but, is a feature of drivers.
 Statement Cache or Pool is associated with a Connection.
 Not all drivers/providers in market support statement caching. To make use of this
feature, make sure you deploy a driver/provider with your database application
which does.
© 2013 Progress Software Corporation. All rights reserved.23
Use Statement Caching/Pooling
 Use statement caching if 90% or more of your statements are executed
multiple times.
 Use Parameterized queries to make best use of Prepared Queries and
statement caching.
 Statement pool max size should not exceed server’s limit for maximum
number of active statements per connection.
 Statement pool max size should be equal or greater than the number of
different statements executed by your application multiple times.
© 2013 Progress Software Corporation. All rights reserved.24
Using Parameter Array Binding/Batches
 To Reduce the number of network roundtrips when updating large amounts of data,
you can bind arrays to parameter value or execute Batches of SQL Statements.
 You can have similar effect while using disconnected Datasets to update the data if
your data provider supports parameter Array binding. To enable this, you can set
DataAdapter.UpdateBatchSize=<No of items in your Array>
 Not all Data Providers and databases supports this feature, make sure you are using a
driver/data provider which does with you database application.
© 2013 Progress Software Corporation. All rights reserved.25
Using Bulk Load
 If your data provider support bulk load (aka BulkCopy), inserting large amount of data
into database server will be even faster than using Array Binding.
 You can use BulkLoad functionality through xxxBulkCopy class which many data
Providers support.
 In Bulk Load, rows are sent as continuous stream, without making extra network
roundtrips. In addition, during Bulk Copy database can also optimize the way the rows
are inserted.
 Bulk Load can have negative impact, as data inserted with bulk load may ignore
referential integrity, causing consistency problems with data in database.
© 2013 Progress Software Corporation. All rights reserved.26
Result Fetching
Improvements
© 2013 Progress Software Corporation. All rights reserved.27
Fetching the Results
Delay Retrieving long data
 Most of the applications do not need
long data by default, but fetching them
is a costly operation.
 Avoid long data columns such as XML,
BLOB, CLOB, NLONGVARCHAR,
LONGVARCHAR, LONGVARBINARY in
the select list.
 Avoid “Select *” queries on tables
which contain long data columns.
Limiting Amount of Data Retrieved
 Use MaxRows or RowSetSize to limit
maximum numbers of rows returned by
the server to Data Provider.
 This will reduce the number of network
round trips.
 Limit the row size, by requesting limited
data of the long columns when
requested. E.g. First 1MB of 10MB long
log entry.
© 2013 Progress Software Corporation. All rights reserved.28
Use Get<Specific-Type> Method to Fetch Data
 Avoid using generic GetValue() to fetch Data From DataReader. It requires extra
processing to convert the value data type to a reference datatype. This process is called
boxing.
 One can avoid boxing by calling Specific Get<Specific-Type>() APIs. E.g. GetInt32()
© 2013 Progress Software Corporation. All rights reserved.29
Choose Right Data Types
Data Type Processing
Binary Transfer of raw bytes from database to application buffers.
int, smallint, float Transfer of fixed formats
Decimal Transfer of proprietary data, Driver must decode which uses CPU.
Usually Convert To String.
Timestamp Transfer of proprietary data, Driver must decode which uses CPU.
Usually Convert To Multipart structure or string.
char Typically transfer of large volume of data which needs code page
translation. Code page translation is usually CPU intensive intensive
and proportional to size of data.
© 2013 Progress Software Corporation. All rights reserved.30
Coding Guidelines
© 2013 Progress Software Corporation. All rights reserved.31
Coding Guidelines
 Executing SQL Statements
• ExecuteNonQuery() – returns number of Rows Affected but does not return actual rows.
– Use this for DML Operations like Insert, Update and Delete.
• ExecuteReader() – Returns DataReader object containing one or more rows of data.
– Use this for Select queries which returns complete Result Set
• ExecuteScalar() – Returns first column of first row of the result set.
– Use this for selects which returns single value is result set (or when application is just
interested in single value first column of first row).
 Though any API can be used for any type of query execution, they are usually
optimized for their specific purpose and contribute to a better performance.
© 2013 Progress Software Corporation. All rights reserved.32
Coding Guidelines
 100% Managed Providers
• Using unmanaged code can significantly impact the performance.
• If managed provider needs unmanaged database clients or other unmanaged pieces
then they are not true managed providers.
• Only few vendors produce true managed providers that work as 100% managed
component.
 Selecting .NET Objects
• Avoid CommandBuilder
• Choosing between DataReader and Datasets
© 2013 Progress Software Corporation. All rights reserved.33
References
THE DATA ACCESS HANDBOOK
Achieving optimal database application Performance and scalability
John Goodson
&
Robert A. Steward
Published By : PRENTICE HALL in 2009
Optimize Data Connectivity in .NET Applications

More Related Content

Optimize Data Connectivity in .NET Applications

  • 1. Optimize Database Connectivity in .NET Applications March 17, 2016 Avadhoot Kulkarni
  • 2. © 2013 Progress Software Corporation. All rights reserved.2 INTRODUCTION Avadhoot Kulkarni Product Owner ODBC, JDBC & ADO.NET Drivers, Progress DataDirect https://www.progress.com/net Avadhoot.Kulkarni@progress.com
  • 3. © 2013 Progress Software Corporation. All rights reserved.3 AGENDA Components of Performance Performance Strategy ADO.NET Data Provider  Architecture of Data Provider  Connection Improvements  Query Execution Improvement  Result Fetching Improvements  Coding Guidelines
  • 4. © 2013 Progress Software Corporation. All rights reserved.4 Components of Performance Database Network Data Provider Data Access Code Client Infrastructure
  • 5. © 2013 Progress Software Corporation. All rights reserved.5 Do not fix your applications for better performance, Design it to perform better. PERFORMANCE STRATEGY
  • 6. © 2013 Progress Software Corporation. All rights reserved.6 Architecture
  • 7. © 2013 Progress Software Corporation. All rights reserved.7 Architecture of Data Provider  Architecture • Managed vs. Unmanaged • How well you manage the resources – Database Capabilities – Network Bandwidth – Disk I/O – CPU – Memory
  • 8. © 2013 Progress Software Corporation. All rights reserved.8 Connection Improvements
  • 9. © 2013 Progress Software Corporation. All rights reserved.9 Connection Improvements  Avoid XA (Distributed Transaction) Enabled Connections (Enlist)  Use Connection Pooling • Benefit • Pooling strategies • When to avoid  Use Bigger Protocol Packet Sizes  Avoid Distributed Transactions  Choose Extended Security Wisely
  • 10. © 2013 Progress Software Corporation. All rights reserved.10 Use Connection Pooling 1. Application Server Started; Connection Pool is populated 2. Application Makes a Connection Request 3. A pooled Connection is given to application. 4. Application is Connected to database. 5. When the connection is closed, it is placed back into the pool. Application Server Application
  • 11. © 2013 Progress Software Corporation. All rights reserved.11 When to avoid Connection Pooling  Frequently Restarting Applications They pay upfront cost of populating the pool and hold up resources, which all gets lost when application restarts.  Single User Applications (e.g. Report Writers) If the application needs to establish connection to database once in a while, for single use, resources held by pool hamper the performance more than the pooling could help.  Single User Batch Jobs Pooling offers no advantage to such applications, as they just need one connection. Especially as these batch jobs are executed off ours when there is no real load on server.
  • 12. © 2013 Progress Software Corporation. All rights reserved.12 Use Bigger Protocol Packet Size  Communication packet size is limited to Servers max packet size limit.  Typically, larger the packet size, the better the performance
  • 13. © 2013 Progress Software Corporation. All rights reserved.13 Avoid Distributed Transactions  Distributed Transactions are used to execute atomic operations across multiple connections. These are needed to keep data consistent.  Requires communication between multiple servers, Hence are very slow compared to local transactions.  This co-ordination could be between several types of database servers e.g. SQL Server, Oracle, DB2, Sybase, MySQL etc. or, multiple instances of same database types.  Be very cautious while designing applications; multiple databases architecture would most likely require distributed transactions.
  • 14. © 2013 Progress Software Corporation. All rights reserved.14 Choose Extended Security Wisely  Performance Penalties are side effects of extended security. Let’s see if its possible to limit them…  There are 2 types to the extended security • Network Authentications • Data Encryption over Network
  • 15. © 2013 Progress Software Corporation. All rights reserved.15 Improve Kerberos Authentication Performance  Bottle Neck: As for each connection, client need to get a ticket from Kerberos server, it can quickly become a bottle neck if it’s a shared server with lots of network heavy services running on it.  Place Kerberos Server on Dedicated machine  Reduce Networking services run on this machine to bare minimum  Make sure you have fast, reliable network connection to the machine
  • 16. © 2013 Progress Software Corporation. All rights reserved.16 Avoid Unnecessary Data Encryption  For secure transition of data another layer is added over TCP/IP i.e. SSL or any proprietary Encryption of database vendor.  Performance Intensive steps • Initial Handshake • Encryption and Decryption  Usually longer the Cipher Key means more the security but lesser the performance.  Use encrypted connections for sensitive data and unencrypted for non-sensitive data. Though, not all databases supports this functionality.
  • 17. © 2013 Progress Software Corporation. All rights reserved.17 Query Execution Improvement
  • 18. © 2013 Progress Software Corporation. All rights reserved.18 Query Execution Improvements  Use Transactions (Auto-Commit)  Use Prepared Queries  Use Statement Caching/Pooling  Use Parameterized Batching  Use Bulk Protocols
  • 19. © 2013 Progress Software Corporation. All rights reserved.19 Use Transactions (Auto-Commit=FALSE)  In ADO.NET Default Auto Commit Mode is TRUE.  DB2 do not support Auto-Commit mode, Data Provider by default send commit request after every successful operation.  Application has no control on when the Commit is fired. Mostly it gets fired even when there is nothing to commit.  Every commit and Rollback operation is performance Intensive • Requires Disk I/O and sometimes network roundtrips. Cont.…
  • 20. © 2013 Progress Software Corporation. All rights reserved.20 Use Transactions (Auto-Commit=FALSE)  In most cases you will want to turn off Auto-Commit mode. Start BeginTransaction() to start local transaction in your application.  Leaving transactions active can reduce throughput by holding locks for longer than necessary. Committing transactions in intervals gives best performance with acceptable concurrency.
  • 21. © 2013 Progress Software Corporation. All rights reserved.21 Use Prepared Queries  Calling Command.Prepare() usually compiles the SQL statement into query plan for efficiency.  Available until the connection is closed.  Though initial execution overhead of prepare is high, advantage is realised in subsequent executions.  Some databases like DB2 and Oracle supports Prepare and execute together, which has multiple benefits.
  • 22. © 2013 Progress Software Corporation. All rights reserved.22 Use Statement Caching/Pooling  Statement Pool is group of prepared statements that an application can reuse.  Its not a feature of database systems but, is a feature of drivers.  Statement Cache or Pool is associated with a Connection.  Not all drivers/providers in market support statement caching. To make use of this feature, make sure you deploy a driver/provider with your database application which does.
  • 23. © 2013 Progress Software Corporation. All rights reserved.23 Use Statement Caching/Pooling  Use statement caching if 90% or more of your statements are executed multiple times.  Use Parameterized queries to make best use of Prepared Queries and statement caching.  Statement pool max size should not exceed server’s limit for maximum number of active statements per connection.  Statement pool max size should be equal or greater than the number of different statements executed by your application multiple times.
  • 24. © 2013 Progress Software Corporation. All rights reserved.24 Using Parameter Array Binding/Batches  To Reduce the number of network roundtrips when updating large amounts of data, you can bind arrays to parameter value or execute Batches of SQL Statements.  You can have similar effect while using disconnected Datasets to update the data if your data provider supports parameter Array binding. To enable this, you can set DataAdapter.UpdateBatchSize=<No of items in your Array>  Not all Data Providers and databases supports this feature, make sure you are using a driver/data provider which does with you database application.
  • 25. © 2013 Progress Software Corporation. All rights reserved.25 Using Bulk Load  If your data provider support bulk load (aka BulkCopy), inserting large amount of data into database server will be even faster than using Array Binding.  You can use BulkLoad functionality through xxxBulkCopy class which many data Providers support.  In Bulk Load, rows are sent as continuous stream, without making extra network roundtrips. In addition, during Bulk Copy database can also optimize the way the rows are inserted.  Bulk Load can have negative impact, as data inserted with bulk load may ignore referential integrity, causing consistency problems with data in database.
  • 26. © 2013 Progress Software Corporation. All rights reserved.26 Result Fetching Improvements
  • 27. © 2013 Progress Software Corporation. All rights reserved.27 Fetching the Results Delay Retrieving long data  Most of the applications do not need long data by default, but fetching them is a costly operation.  Avoid long data columns such as XML, BLOB, CLOB, NLONGVARCHAR, LONGVARCHAR, LONGVARBINARY in the select list.  Avoid “Select *” queries on tables which contain long data columns. Limiting Amount of Data Retrieved  Use MaxRows or RowSetSize to limit maximum numbers of rows returned by the server to Data Provider.  This will reduce the number of network round trips.  Limit the row size, by requesting limited data of the long columns when requested. E.g. First 1MB of 10MB long log entry.
  • 28. © 2013 Progress Software Corporation. All rights reserved.28 Use Get<Specific-Type> Method to Fetch Data  Avoid using generic GetValue() to fetch Data From DataReader. It requires extra processing to convert the value data type to a reference datatype. This process is called boxing.  One can avoid boxing by calling Specific Get<Specific-Type>() APIs. E.g. GetInt32()
  • 29. © 2013 Progress Software Corporation. All rights reserved.29 Choose Right Data Types Data Type Processing Binary Transfer of raw bytes from database to application buffers. int, smallint, float Transfer of fixed formats Decimal Transfer of proprietary data, Driver must decode which uses CPU. Usually Convert To String. Timestamp Transfer of proprietary data, Driver must decode which uses CPU. Usually Convert To Multipart structure or string. char Typically transfer of large volume of data which needs code page translation. Code page translation is usually CPU intensive intensive and proportional to size of data.
  • 30. © 2013 Progress Software Corporation. All rights reserved.30 Coding Guidelines
  • 31. © 2013 Progress Software Corporation. All rights reserved.31 Coding Guidelines  Executing SQL Statements • ExecuteNonQuery() – returns number of Rows Affected but does not return actual rows. – Use this for DML Operations like Insert, Update and Delete. • ExecuteReader() – Returns DataReader object containing one or more rows of data. – Use this for Select queries which returns complete Result Set • ExecuteScalar() – Returns first column of first row of the result set. – Use this for selects which returns single value is result set (or when application is just interested in single value first column of first row).  Though any API can be used for any type of query execution, they are usually optimized for their specific purpose and contribute to a better performance.
  • 32. © 2013 Progress Software Corporation. All rights reserved.32 Coding Guidelines  100% Managed Providers • Using unmanaged code can significantly impact the performance. • If managed provider needs unmanaged database clients or other unmanaged pieces then they are not true managed providers. • Only few vendors produce true managed providers that work as 100% managed component.  Selecting .NET Objects • Avoid CommandBuilder • Choosing between DataReader and Datasets
  • 33. © 2013 Progress Software Corporation. All rights reserved.33 References THE DATA ACCESS HANDBOOK Achieving optimal database application Performance and scalability John Goodson & Robert A. Steward Published By : PRENTICE HALL in 2009

Editor's Notes

  1. Introduction of Presenter 10 Years of Experience in Database driver development Product Owner of ODBC, JDBC and ADO.NET Drivers. Owning ADO.NET Products for last 3 Years ADO.NET Product lines currently supports Connectivity to Oracle, DB2, Microsoft SQL Server and Sybase ASE. Entity Framework 6.0 Support for Oracle and DB2 for i.
  2. What we are going to cover Not Covering Entity Framework in this session, if interested pleas get back to us and we would try to schedule something. Will stay focused on the core ADO.NET Connectivity to Relation Databases for this session.
  3. Different components of Performance and How does it impacts. Database – Database tuning, indexing, normalizations are still important part of performance improvements. CPU, Memory, Network bandwidth, sharing of resources all becomes imp. Network – This is one of the critical resource which impacts the performance. Fewer the network round trips better the performance. Example Data provider – Provider architecture, Configurations and how it handles the system resources are key factors Data Access Code – A well written Data Access Code helps Data provider to optimize the executions and improve performance, we will touch on this Client Infrastructure – Not only Database server, but resources available on client are also play important part in overall performance of the application
  4. Performance Strategy : Usually we build an application to meet a business requirement; and then once we notice a performance issue; we reactively try and fix the performance problems. This is very costly as appose to designing the application proactively with performance as an important design criteria. Here are some design guidelines on how to make best use of your data Adaptor in your application...
  5. Managed vs Un-Managed Managed Architecture provides a lot more than just performance, Garbage Collector, Type Safetly, Code Access Security are just few advantages to mention. Unmanaged calls P/Invokes requires security context switching which has high cost. The Data provider should be smart to utilize the resources on both server and client wisely to improve performance, each of these sub-items can impact the performance of your application.
  6. Distributed Transaction Enabled Connections take more time and Resources on server to create on few backend e.g. DB2 We will discuss each of them in coming slides
  7. Connections – Opening a Connection is very expensive Sets up Environment on both client and Server side with required memory buffers Opens Sockets/communication channel, Certificate/Key Validations in case of SSL/Encryptions. Connection Pooling is a mechanism to reuse the existing sets of Connections and avoid the multiple open and close calls for better performance Fix Size of Pool Strategy 1: Fill up the pool with connections at the start of application. Drawback, slow start Strategy 2: Open the connection only once needed, if matching connection found in pool, loaded from there, else create new one. Close as soon as the work is done, so that it will be available for next request. More complex strategies like FIFO, LIFO etc.
  8. Protocol Packet Size defines numbers of bytes can be transferred in single network round trip. All database instances and Data Providers can be configured to a max value for this packet size. This max Packet size is used by database server and data providers to initialize the internal arrays/structures required for communication. Actual Communication Packet size is Minimum of Server’s Max Packet Size and Clients Max Packet Size. More the Packet Size, less are the network roundtrips to transfer the same data across, Hence better the performance
  9. Distributed Transaction: Transaction spanning multiple connection for same database or across multiple databases. Suppose a company has different databases for their payroll and accounting. Employee Salary operations needs to update both of these as an atomic operation.
  10. Initial Handshake Multiple round trips Certificate or Key Validation Cipher Negotiations Usual Connection stuff
  11. Auto Commit TRUE means Commit is performed after every SQL statement that servers as request to server i.e. Insert, Update, Delete and Select.
  12. Because the database objects/rows/pages are locked by transactions they have negative impact on the throughput. The choice of Isolation Levels also determines this impact.
  13. Server can use this cached query plans for multiple executions of same statement without any overhead. Benefit 1: It reduced extra round trip of prepare and execute separate. Benefit 2: You don’t have to keep track of which statements you have prepared for multiple executions and which you have not. Dynamic queries (which uses Parameters) are better than static (which use literals) for performance, as dynamic queries can be prepared once and executed multiple time with different parameter values.
  14. If your application has same statements executed multiple times, then statement caching/pooling can help a lot in the performance improvement.
  15. In ArrayBinding, all the parameters Values are passed to the server in single go. It reduces the network round trips, compared to one row at a time approach. If you set DataAdapter.UpdateBatchSize property; Data Providers will internally use ArrayBinding Mechanism to speed up the execution.
  16. Bulk Load is done through the Specialized protocols exposed by database vendor to fast uploading of data. Not all database vendors or data providers support this functionality. Microsoft Tools like SSIS also can benefit from BulkLoad functionality to insert large amount of data.
  17. Writing SQL Statements to Fetch limited LOB data Facebook –Read More… Oracle - LOB Pre-fetch This helps in prefetching the LOB contents, chunk size and actual size along with the statement execution, without doing additional round trips. This will be beneficial especially if LOB sizes are small.
  18. Boxing and Unboxing is a performance hit compared to the normal assignment operations. If you are fetching high volume of data in your application, the performance hit because of this can quickly become considerable.
  19. The DataTypes are listed in the order of the post-processing needed by data providers, after fetching them from the server. If your application is fetching huge amount of data from the server, choosing the right datatypes can save you very important CPU cycles.
  20. ExecuteNonQuery - Do not fetch resultset description, which saves valuable network roundtrips. Do not allocate/deallocate buffers to store the resultset descriptions on client/application server side. ExecuteScalar - As it needs just first Column of first row; it can limit the amount of data retrieved.
  21. CommandBuilder You can manually write a lot better (performant) update, insert or delete queries than CommandBuilder can possibly generate. Though it is exciting to use CommandBuilder, as it provides speed of development, it hampers the application performance. DataReader vs DataSets If your application is fetching huge amount of read only data, DataReader is a better choice, which is memory efficient. If you application needs to be used in disconnected environment, with non-sequential updates, then DataSet it a better choice.
  22. Thank You. Questions?