Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4110108
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:53:27+00:00 2026-05-20T21:53:27+00:00

I have a web application that loads some 50 tables from SQL Server into

  • 0

I have a web application that loads some 50 tables from SQL Server into a DataSet, builds a more complex data structure based on it, and then caches the data so that the web application can execute faster.

The initial load of the application takes around 10 seconds, half of which is simply loading data from the database tables. Although this is reasonable in production, it gets frustrating in development. I want to speed things up.

What I have currently is similar to the following pseudo-code:

var ds = new DataSet();
var tablesToFill = new List<string>() { ... };
connectToDatabase();
foreach (var t in tablesToFill) fill(ds, t);
disconnectFromDatabase();

The fill(DataSet, string) method basically fills in something similar to an ‘Select * from {tablename};’ into the DataSet.Tables[tablename]

I wondered if loading in parallel would make things faster.

First, I added MultipleActiveResultSets=true to my connection string (SqlClient). Then, I tried the following pseudo-code:

var ds = new DataSet();
var tablesToFill = new List<string>() { ... };
connectToDatabase();
ds.EnforceConstraints=false; // without this, get concurrency errors in DataSet
tablesToFill.AsParallel().ForAll(t => fill(ds,t));
ds.EnforceConstraints=true;
disconnectFromDatabase();

This appears to work fine. On a subset of two dozen tables, load times are slashed by 66% (2.7 seconds to 0.9 seconds).

Is there anything I should be aware of that could come back and haunt me later? According to MSDN, I’m supposed to synchronize write operations on DataSets but since they’re all writing to different tables, things appear to work fine. However, am I just being lucky and/or are there scenarios (or versions of .NET) where this could bring trouble?

Thanks!

Edit: Thinking further, if you feel this is dangerous due to thread safety, how about having each fill work on its own distinct DataSet in parallel and then moving all the DataTables into a common DataSet (in the same thread). I assume I can detach & re-attach a DataTable from one DataSet to another very quickly (O(1) time, without having to duplicate any data).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:53:28+00:00Added an answer on May 20, 2026 at 9:53 pm

    how about having each fill work on its own distinct DataSet in parallel and then moving all the DataTables into a common DataSet (in the same thread)

    Why not fill separate DataTables and then add the DataTables to the DataSet.

    Wait until the last DataTable is filled before putting them in the DataSet and there should be no issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that has a page that loads the content from
I have a web application that dynamically loads assemblies based on database configuration entries
We have a web application that is generating some 3-5 parallel threads every five
I have a web application that loads javascript on page load: $(function() { $('.modal-delete').click(function()
I have a web application that can load plugins through reflection. It currently uses
I have a web application that allows users to enter search criteria and the
I have a web application that will be used on iPhones, and want to
I have a web application that maintains a version flag as a ServletContext.setAttribute('flag', flagValue)
I have a web application that has a constant URL and internal state machine.
I have a Web Application that use Hibernate 3.0. When I restart my database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.