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

  • SEARCH
  • Home
  • 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 8792193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:56:45+00:00 2026-06-13T22:56:45+00:00

We have a performance problem in production, we are trying to solve. During our

  • 0

We have a performance problem in production, we are trying to solve. During our attempt to solve it, we have our eyes on the datatable.

Our flow:

  1. We run a select query on the database
  2. Put the data into a DataTable
  3. We write out all the data into a StringBuilder with a separator
  4. The StringBuilder writes all text into the Response.Write, which builds a CSV file

The problem is in production, our client says the operation times out. We can’t reproduce the timeout in development, which might be because of the amounts of data in production.

Step 1:

We’ve run a profiler on the select query, and that runs really fast.

Step 2:

We have the following code:

SqlDataReader reader = searchQuery.ExecuteReader();
returnTable.Load(reader);

Step 3:

We iterate the returnTable like this:

foreach (DataRow order in orders.Rows)
{
      trackingNumber = order["TrackingNumber"] != null ? order["TrackingNumber"].ToString() : errString;
      created = order["Created"] != null ? ((DateTime)order["Created"]).ToString() : errString;
      // rest of the fields
}

Step 4:

HttpContext.Current.Response.Write(bld.ToString());

Now, when we have run step 2, what happens? Is the DataTable fully loaded?

I could see a problem if we poll the database in each and every row in step 3, as that could slow our process. But if it loads it all at once, I can’t see how this could be a problem.

So basically: does the DataTable load everything at once, or does it use lazy loading?

  • 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-06-13T22:56:46+00:00Added an answer on June 13, 2026 at 10:56 pm

    when we have run step 2, what happens? Is the datatable fully loaded?

    All the values returned by the query will be transferred to the application and loaded into the DataTable.

    does it use lazy loading?

    No, it doesn’t.


    What you can do:

    • Consider a bounded query – only return the top 100 rows (or whatever is applicable). If there are thousands, it is unlikely to be of use.
    • With the above, consider using paging to only fetch and display a bounded result set.
    • Optimize the query. That it runs fast in testing, doesn’t mean the query is optimal. You may want to test this on a similar amount of data the your client has.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a performance problem on a query. First table is a Customer table
The problem: I have a WCF service that I'm trying to performance test with
we have faced a problem with our production system yesterday which I am unable
I have a strange performance problem with a query used to create a filter
I have a performance problem related to string comparison (in Java). I'm working on
I have got a performance problem about TextField.htmlText +=msg .And I know that TextField.appendText(msg)
I have a serious performance problem. I have a database with (related to this
So I have a bit of a performance problem. I have made a java
I have problem with my widget related to performance and memory: Issue : My
I have a problem with SHA-1 performance on Android. In C# I get calculated

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.