views:

43

answers:

2

I'm writing an application in vb.net 2005. The app reads a spreadsheet into a DataSet with ADO.NET and uses a column of that table to populate a ListBox. When a ListBox Item is selected, the user will be presented with detailed information on the selected record.

One part of this information isn't in the DataSet. I have to compare a column from the spreadsheet with several external data sources to determine the nature of the record in question. Here's where I have my problem.

This comparison has to search through 9.5m rows in a SQL table at one stage. I've checked and there's no way to "shrink" the query down as I'm already only searching absolutely essential data.

What happens is that the application never visibly does anything. The CPU usage shoots up to 100% regardless of what it was at beforehand and the system's performance becomes almost unbearably slow.

Can anyone suggest a way I can improve this situation while this massive query is running?

EDIT: I was originally going to write the contents of the 9.5m rows in the database table to a text file which I'd then read from, but after 6.5m rows, I got an OutOfMemoryException.

+1  A: 
  1. An index in the column to search?
  2. A new field in the table to help to search faster?
onof
1. I need to search by a specific column and I'm doing that.2. Can you elaborate on a new field in the table to help search faster?The database contains the company's client information and I need to go through a few approvals before I can make changes to the table schemas. Knowing my boss, I highly doubt he'll see that it's necessary.
Logan Young
If the search is something like Color = 'Red' you could add an integer column where you can insert, enumerated possible values of Color, or, in Oracle a bitmap index could help.
onof
Logan Young
+3  A: 

I suspect your CPU might be used in populating the DataSet, though you would have to profile your application to confirm that. Try using a DataReader instead and either storing the results in some more compact format in memory or, if you're running out of memory, then writing them to a file as you go. With the DataReader approach you never need to store the entire result set in memory at the same time.

Evgeny
CORRECT! I tried the DataReader and the results appeared on my form almost instantly. A significant improvement on the DataSet approach.Thanks for the tip :)
Logan Young