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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:26:23+00:00 2026-05-22T21:26:23+00:00

Let’s say I have a relatively large list of an object MyObjectModel called MyBigList

  • 0

Let’s say I have a relatively large list of an object MyObjectModel called MyBigList. One of the properties of MyObjectModel is an int called ObjectID. In theory, I think MyBigList could reach 15-20MB in size. I also have a table in my database that stores some scalars about this list so that it can be recomposed later.

What is going to be more efficient?

Option A:

   List<MyObjectModel> MyBigList = null;

   MyBigList = GetBigList(some parameters);

   int RowID = PutScalarsInDB(MyBigList);

Option B:

   List<MyObjectModel> MyBigList = null;

   MyBigList = GetBigList(some parameters);

   int TheCount = MyBigList.Count();

   StringBuilder ListOfObjectID = null;

   foreach (MyObjectModel ThisObject in MyBigList)
   {
      ListOfObjectID.Append(ThisObject.ObjectID.ToString());
   }

   int RowID = PutScalarsInDB ( TheCount, ListOfObjectID);

In option A I pass MyBigList to a function that extracts the scalars from the list, stores these in the DB and returns the row where these entries were made. In option B, I keep MyBigList in the page method where I do the extraction of the scalars and I just pass these to the PutScalarsInDB function.

What’s the better option, and it could be that yet another is better? I’m concerned about passing around objects this size and memory usage.

  • 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-22T21:26:24+00:00Added an answer on May 22, 2026 at 9:26 pm

    I don’t think you’ll see a material difference between these two approaches. From your description, it sounds like you’ll be burning the same CPU cycles either way. The things that matter are:

    • Get the list
    • Iterate through the list to get the IDs
    • Iterate through the list to update the database

    The order in which these three activities occur, and whether they occur within a single method or a subroutine, doesn’t matter. All other activities (declaring variables, assigning results, etc.,) are of zero to negligible performance impact.

    Other things being equal, your first option may be slightly more performant because you’ll only be iterating once, I assume, both extracting IDs and updating the database in a single pass. But the cost of iteration will likely be very small compared with the cost of updating the database, so it’s not a performance difference you’re likely to notice.

    Having said all that, there are many, many more factors that may impact performance, such as the type of list you’re iterating through, the speed of your connection to the database, etc., that could dwarf these other considerations. It doesn’t look like too much code either way. I’d strongly suggesting building both and testing them.

    Then let us know your results!

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

Sidebar

Related Questions

Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a C++ Visual Studio 2010 solution with 2 projects: one
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let's say I have a domain object with the following field: private Map<StatType, Double>
Let's say that I have classes like this: public class Parent { public int
Let's say I have a large amount of files, say 20GB worth, all encrypted
Let's say I have 2 functions: void function1(int *ptr) { printf(%d, *ptr); } and

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.