| Details | ![]() |
| QuickDocId | 523 |
| Written by | Imar Spaanjaars |
| Posted | 03/20/2010 15:40 |
| Page views | 3175 |
Are you looking to hire an experienced software developer or .NET consultant? Then get in touch with me through my company's web site at devierkoeden.com
Found an interesting article on this site? Got inspired by something you read here? Then consider making a donation with PayPal.
I was running the application locally, from within Visual Studio, but the database was still on our corporate network which I accessed through our VPN. The application was slow beyond imagination. I had to wait a few minutes for a simple page with a few pictures to completely load. At first I blamed the VPN, but other applications seemed to work fine. Then I blamed the database server in our network, but again, other applications running against the same development server seemed to work fine. A quick debug session revealed the real problem: we were not doing database paging, but application paging. So instead of telling SQL Server to do its magic and have it return 12 records to fill a "page" based on the search, filter and paging criteria, we got all records from the database that matched the search criteria and did filtering and paging inside the application. Depending on how you accessed the application and what pages you visited, that could literally mean we copied hundreds of thousands of records from the database to the application and then brought the list down to the 12 that needed to be displayed. That worked find on a fast LAN with only a few users. But it clearly revealed I had created a serious architectural problem once I tried to download those hundreds of thousands of records over a slow VPN connection. Once I identified that potential performance killer, the fix was easy: we moved the complete searching, filtering and paging mechanism to the database; in a bunch of stored procedures in our case. The database does what it needs to do, find the records the user is interested in, and only returns the "page" of records that needs to be displayed.
So what's the moral of this story? When you test applications, you need a good, representative data set and you need to try to mimic the final application circumstances as much as possible. In my case, I was lucky enough to have a representative set of over 250,000 pictures, but that's not always the case.
The other day I was working on the architecture of a reporting application that needs to show pivot tables and sums of sales over the past couple of years. To see how the application would behave, I wrote a couple of test reports to do the pivoting and grouping. However, entering enough test data by hand to create a representative set of data with possibly hundreds of thousands of records wasn't a very appealing thought. Then I rediscovered Red Gate's Data Generator; a tool I had used briefly in the past but had forgotten about since. With Data Generator, generating data is extremely simple. You point to a database, configure what data you want inserted and where and Data Generator does the rest for you. What I really like is the way the tool is able to recognize column names and then provide data that's appropriate for that column. The product ships with a large number of predefined generators for many of the "usual suspects" you come across in a database, such as first names, last names, address details, phone numbers, foreign key look ups, IDs, numbers and more. This makes it very simple to generate large amounts of test data that looks as real as possible.
To see how this works, consider my "Contact Manager Application" that I have written about extensively in my series on N-Layer Design. The application features a simple database model with a table for contacts and three related contact data tables for addresses, e-mail addresses and phone numbers, shown in Figure 1.

Figure 1
To generate data for this model, I came up with the following specifications:
To accomplish these steps I configured Data Generator as follows:



[1-99]{2}|[1-99]{2}[a-f]{1}
public enum ContactType
{
/// <summary>
/// Indicates an unidentified value.
/// </summary>
None = 0,
/// <summary>
/// Indicates a business contact record.
/// </summary>
Business = 1,
/// <summary>
/// Indicates a personal contact record.
/// </summary>
Personal = 2
}
The 0 option shouldn't be valid in the database, so I want to insert either 1 or 2 as the contact type. With the Weighted List generator this is pretty easy. Just enter the value you want to insert and provide a relative weight.

Figure 5
The cool thing about this option is that you can provide a relative weight to each unique value. In the settings shown in Figure 5, it means I'll end up with twice as many Business addresses as Personal addresses.


I can see lots of situations or applications where generating test data like this is extremely useful. No more test pages with only one or two test records (often labeled asdf of qwrew), but real, representative data, and lots of it. This makes it easier to test your application, and find potential flaws in the design or architecture at design time, way before your application goes live and accumulates this amount of real data. Red Gate's Data Generator is definitely worth checking out if you're serious about generating test data for your application.
Now, all I need to find is that "Simulate Slow VPN Connection" check box in SQL Server's Options dialog, and I am good to go to do some real-world testing.
Wonder where to go next?
You can read existing comments below
or you can post a comment yourself on this article.
Consider making a donation
Please consider making a donation using PayPal. Your donation helps me to pay the bills so I can keep running Imar.Spaanjaars.Com, providing fresh content as often as possible.
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.
When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.
If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the QuickDocId of the document.
For more information about the Talk Back feature, check out this news item.
| QuickDocId | 523 |
| Full URL | http://imar.spaanjaars.com/523/avoiding-the-works-on-my-machine-syndrome |
| Short cut | http://imar.spaanjaars.com/523/ |
| Written by | Imar Spaanjaars |
| Date Posted | 03/20/2010 15:40 |