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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:16:35+00:00 2026-06-17T13:16:35+00:00

There’s following web method that is being used in our legacy web service. [WebMethod(Description

  • 0

There’s following web method that is being used in our legacy web service.

[WebMethod(Description = "Get Bulk Data")]
public string[] getBulkData(string[] arrInput)
{
    string[] arrResults = new string[arrInput.Length];  
    using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mydb"].ToString()))
    {
        conn.Open();
        //some db operations...
        for (int arrIndex = 0; arrIndex < arrInput.Length; arrIndex++) //arrInput size can be very large
        {
             arrResults[arrIndex] = getResult();
        }
    }
    return arrResults;            
}
private string getResult()
{
    string r;
    using (SqlConnection thisConn = new SqlConnection(ConfigurationManager.ConnectionStrings["mydb2"].ToString()))
    {
        //some db operations
        //assign values to r
    }
    return r;
}

The web method, getBulkData, takes an array of string, queries the databse and returns an array of results with same size. The results come from a private method, getResult() which will also query the database.

I am not sure if it’s the right implementation here, but I’d tend to say it’s not, because there’re multiple querying database, which would probably impact getBulkData’s performance. Apparently, the more elements have in that array, the longer processing takes.

If I create thisConn object in getBulkData(), and pass it into getResult, would that make any difference in terms of improving performance? And what’d be the best way to handle a large array in this case?

  • 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-17T13:16:36+00:00Added an answer on June 17, 2026 at 1:16 pm

    Database transactions take time to process. If you’re querying the database hundreds or thousands of times in a loop, your performance will definitely take a hit. If possible, try to modify the GetResult method to only fire once, but save the results in an property of type IEnumerable. That puts all of the records in your computer’s memory and will allow you to run queries against it with LINQ. You’ll see a substantial performance increase using this approach. You can see an example here.

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

Sidebar

Related Questions

There are a lot of blogs saying that a hasOwnProperty check should be used
There is a use case that is quite popular when building international web application:
There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
That's pretty much it. I'm using Nokogiri to scrape a web page what has
There is a table Customers with a nullable cstCredit column. The following works fine
There's a map with points: The green number next to each point is that
There are 3 different ways to get data out of a BLOB column from
I know there's a lot of other questions out there that deal with this

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.