views:

47

answers:

5

One of my web pages populates a droplist with about 60k items pulled from SQL Server, and this operation takes upwards of 10 seconds to complete. Are there some tricks or optimizations I can try to improve performance? I'm using a SqlDataSource configured as a DataReader.

Thanks for any help.

+2  A: 

Any operation that gets a large amount of data from the DB will take a while.

Populating a dropdown with that many items will also take some time as will transmission of the resulting html to the browser.

Not to mention that 60k items in a dropdown list is not very usable.

The optimisation is to change your application so it doesn't need 60k items in one go.

Perhaps a paged approach is more appropriate, where you only get a small subset of the data at a time and can display different parts of it.

You can consider an autocomplete as another option.

Oded
I've considered that, but I don't think it would work too well. What I'm working with is a database containing records of every product we've manufactured. This particular page allows a user to view product information based on serial number. The user can either type in the sn if known, or look for it in a drop down list.
Curtis
So, they know what they are looking for in a dropdown - can't you use a string as a search term to pick up products?
Oded
@Curtis - why would it not work well to try another approach? You've exceeded the reasonable number of records for presentation in a dropdown. Perhaps list your product inventory by category? Imagine if Amazon listed all of their CDs in a dropdown? It just isn't practical. You need to make your product list available in another way, perhaps via serial number search, product title search, browsed paging, and product categories.
alex
@Curtis: couldn't you create a little popup view with a filtering capability? E.g. show me all the "widgets" we've ever produced, and then get back a manageable list of products? 40K items in a dropdown seems quite unmanageable to me...
marc_s
+1  A: 

Check if you're doing a SELECT *

Change the call to the database to a Stored Procedure or View

Try dumping the result into the ASP.Net Cache and check if that's null before querying the database again.

hunter
+2  A: 

60,000 items is going to be way too much both for performance and from the user's perspective. Try either cascading dropdown (if it makes sense) or an autocomplete.

sestocker
A: 

I think putting 60k into a dropdown is not that useful, I would suggest switching to some sort of auto complete solution.

cgreeno
A: 

As others have stated, I think you should expend some energy pondering the necessity of retrieving 60k records in one shot. Can you not provide some sort of cascading functionality so that only a subset at a time is required? Or perhaps an auto-complete search function? There's got to be a better way. And just think, not only will you improve the database performance, but you'll likely enhance usability in the process!

alex