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 6557375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:03:58+00:00 2026-05-25T13:03:58+00:00

I have a very large dataset which I am currently writing out to a

  • 0

I have a very large dataset which I am currently writing out to a text file (IO). It is very slow and causing the system to chew up a lot of resources as there are 10’s of thousands of rows.

I’m wondering if anybody can recommend a good way to do this to reduce the load on my system or at least smooth out the process to avoid big spikes in demand for memory resources etc. I don’t mind if it means it takes longer, but as long as it’s not putting too much load on the machine.

  • 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-25T13:03:59+00:00Added an answer on May 25, 2026 at 1:03 pm

    Your question hardly makes sense, but assuming you are reading the results from database in chunks you could write them in chunks to the file to avoid loading the entire dataset in memory, just like so:

    using (var conn = new SqlConnection(SomeConnectionString))
    using (var cmd = conn.CreateCommand())
    {
        conn.Open();
        cmd.CommandText = "SELECT foo, bar FROM baz;";
        using (var reader = cmd.ExecuteReader())
        {
            using (var writer = new StreamWriter("result.txt"))
            {
                while (reader.Read())
                {
                    var foo = reader.GetString(reader.GetOrdinal("foo"));
                    var bar = reader.GetInt32(reader.GetOrdinal("bar"));
                    writer.WriteLine(string.Format("{0}, {1}", foo, bar));
                }
            }
        }
    }
    

    In terms of memory consumption this will Rock’N’Roll and in terms of performance it would of course depend on the optimization of your SQL query and the capabilities of your SQL server.

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

Sidebar

Related Questions

I have to migrate a very large dataset from one system to another. One
I have a very large XML file which has like 40000 data, and when
I have an application which predictably generates out-of-memory errors on very, very (very) large
I have a very large Excel sheet converted from a 6000 page PDF file,
I have a very large data file with around 60000 rows. I need to
I need to read from a dataset which is very large, highly interlinked, the
I am trying to deal with a very large dataset. I have k =
I have a very large dataset (100,000) to be display, but any browser I
I have a large dataset and have defined outliers to be those values which
So I have a very large project which when run prints a data set

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.