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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:41:04+00:00 2026-05-17T22:41:04+00:00

I have a C++ application that loads lots of data from a database, then

  • 0

I have a C++ application that loads lots of data from a database, then executes algorithms on that data (these algorithms are quite CPU- and data-intensive that’s way I load all the data before hand), then saves all the data that has been changed back to the database.

The database-part is nicely separate from the rest of the application. In fact, the application does not need to know where the data comes from. The application could even be started on file (in this case a separate file-module loads the files into the application and at the end saves all data back to the files).

Now:

  • the database layer only wants to save the changed instances back to the database (not the full data), therefore it needs to know what has been changed by the application.
  • on the other hand, the application doesn’t need to know where the data comes from, hence it does not want to feel forced to keep a change-state per instance of its data.

To keep my application and its datastructures as separate as possible from the layer that loads and saves the data (could be database or could be file), I don’t want to pollute the application data structures with information about whether instances were changed since startup or not.

But to make the database layer as efficient as possible, it needs a way to determine which data has been changed by the application.

Duplicating all data and comparing the data while saving is not an option since the data could easily fill several GB of memory.

Adding observers to the application data structures is not an option either since performance within the application algorithms is very important (and looping over all observers and calling virtual functions may cause an important performance bottleneck in the algorithms).

Any other solution? Or am I trying to be too ‘modular’ if I don’t want to add logic to my application classes in an intrusive way? Is it better to be pragmatic in these cases?

How do ORM tools solve this problem? Do they also force application classes to keep a kind of change-state, or do they force the classes to have change-observers?

  • 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-17T22:41:05+00:00Added an answer on May 17, 2026 at 10:41 pm

    If you can’t copy the data and compare, then clearly you need some kind of record somewhere of what has changed. The question, then, is how to update those records.

    ORM tools can (if they want) solve the problem by keeping flags in the objects, saying whether the data has been changed or not, and if so what. It sounds as though you’re making raw data structures available to the application, rather than objects with neatly encapsulated mutators that could update flags.

    So an ORM doesn’t normally require applications to track changes in any great detail. The application generally has to say which object(s) to save, but the ORM then works out what needs persisting to the DB in order to do that, and might apply optimizations there.

    I guess that means that in your terms, the ORM is adding observers to the data structures in some loose sense. It’s not an external observer, it’s the object knowing how to mutate itself, but of course there’s some overhead to recording what has changed.

    One option would be to provide “slow” mutators for your data structures, which update flags, and also “fast” direct access, and a function that marks the object dirty. It would then be the application’s choice whether to use the potentially-slower mutators that permit it to ignore the issue, or the potentially-faster mutators which require it to mark the object dirty before it starts (or after it finishes, perhaps, depending what you do about transactions and inconsistent intermediate states).

    You would then have two basic situations:

    • I’m looping over a very large set of objects, conditionally making a single change to a few of them. Use the “slow” mutators, for application simplicity.
    • I’m making lots of different changes to the same object, and I really care about the performance of the accessors. Use the “fast” mutators, which perhaps directly expose some array in the data. You gain performance in return for knowing more about the persistence model.

    There are only two hard problems in Computer Science: cache invalidation and naming things.

    Phil Karlton

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

Sidebar

Related Questions

I have an application that loads lots of data into memory (this is because
I have a a C# (FFx 3.5) application that loads DLLs as plug-ins. These
I have an application that loads external SWF files and plays them inside a
I have a managed Windows application that loads a managed C++ component that uses
I have an application that reads a CSV file with piles of data rows.
We have an application that runs over load balanced server instances, and therefore is
I have an application that sends messages to an external web service. I build
I have an application that displays an image inside of a Windows Forms PictureBox
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have an application that I would like to embed inside our companies CMS.

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.