Databases Reference
In-Depth Information
Table 9-1. Coding Strategies to Design for Performance
Technique
Comments
Bulk data loading/changing
Minimizes roundtrips by using a data access library that supports loading data in
bulk, such as the Entity Framework.
Lazy loading
Allows you to create objects for which certain properties are loaded only when
first called, to minimize loading unnecessary data (and improve performance).
The Entity Framework 4.0 supports this.
Caching
Lets you to keep in memory certain objects that don't change frequently.
The caching application blocks provided by Microsoft offer this capability as well
as expiration and scavenging configuration settings.
Asynchronous user interface
Not technically a performance-improvement technique, but allows users to use
the application while your code is performing a long-running transaction and
thus provides a better user experience.
Parallel processing
Allows you to run code on multiple processors for optimum performance.
Although complex, this technique can provide significant performance
advantages.
Shards
Lets you to store data in multiple databases to optimize reads and spread the load
of queries over multiple database servers.
Because shards are considered a newer technology, the remainder of this chapter focuses on building an HPS
using caching and parallel processing in order to improve performance and scalability.
Building a Shard
Let's build a shard library that can be used by applications that need to load and update data against multiple SQL
Database instances as quickly and transparently as possible. The shard we are building uses a collection of databases
as its underlying storage; however, there is no data affinity. A record could be located in any database; the approach
uses a round-robin insert mechanism when adding data. For the purpose of building an efficient shard library, you
stipulate the following requirements for the shard:
1.
Adding new databases should be simple and transparent to the client code.
2.
Adding new databases shouldn't affect performance negatively.
3.
The library should function with SQL Server, SQL Database, or both.
4.
The library should optionally cache results for fast retrieval.
5.
The library should support mass or selective reads and writes.
6.
Data returned by the library should be accepted as a data source for controls.
These requirements have very specific implications from a technology standpoint. Table 9-2 outlines which
requirements are met by which technology.
 
 
Search WWH ::




Custom Search