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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:30:12+00:00 2026-05-29T18:30:12+00:00

I am looking for a way to search in an efficient way for data

  • 0

I am looking for a way to search in an efficient way for data in a huge multi-dimensional matrix.

My application contains data that is characterized by multiple dimensions. Imagine keeping data about all sales in a company (my application is totally different, but this is just to demonstrate the problem). Every sale is characterized by:

  • the product that is being sold
  • the customer that bought the product
  • the day on which it has been sold
  • the employee that sold the product
  • the payment method
  • the quantity sold

I have millions of sales, done on thousands of products, by hundreds of employees, on lots of days.

I need a fast way to calculate e.g.:

  • the total quantity sold by an employee on a certain day
  • the total quantity bought by a customer
  • the total quantity of a product paid by credit card
  • …

I need to store the data in the most detailed way, and I could use a map where the key is the sum of all dimensions, like this:

class Combination
   {
   Product *product;
   Customer *customer;
   Day *day;
   Employee *employee;
   Payment *payment;
   };

std::map<Combination,quantity> data;

But since I don’t know beforehand which queries are performed, I need multiple combination classes (where the data members are in different order) or maps with different comparison functions (using a different sequence to sort on).

Possibly, the problem could be simplified by giving each product, customer, … a number instead of a pointer to it, but even then I end up with lots of memory.

Are there any data structures that could help in handling this kind of efficient searches?

EDIT:

Just to clarify some things: On disk my data is stored in a database, so I’m not looking for ways to change this.

The problem is that to perform my complex mathematical calculations, I have all this data in memory, and I need an efficient way to search this data in memory.

Could an in-memory database help? Maybe, but I fear that an in-memory database might have a serious impact on memory consumption and on performance, so I’m looking for better alternatives.

EDIT (2):

Some more clarifications: my application will perform simulations on the data, and in the end the user is free to save this data or not into my database. So the data itself changes the whole time. While performing these simulations, and the data changes, I need to query the data as explained before.

So again, simply querying the database is not an option. I really need (complex?) in-memory data structures.

  • 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-29T18:30:13+00:00Added an answer on May 29, 2026 at 6:30 pm

    EDIT: to replace earlier answer.

    Can you imagine you have any other possible choice besides running qsort( ) on that giant array of structs? There’s just no other way that I can see. Maybe you can sort it just once at time zero and keep it sorted as you do dynamic insertions/deletions of entries.

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

Sidebar

Related Questions

I'm looking for a way to search a file system that contains approximately 1TB
I am looking for a way to search through every users profile using the
I'm looking for a way to search through our subversion repository or just packaged
While looking for a way to temporarily save the search results when a user
I'm looking for a way to make the search/replace function of VS IDE regex-aware,
I'm currently looking for a way to search a big database (500MB - 10GB
I'm looking for some general advice on the most efficient way to go about
I am looking for an efficient way to find out if a resource (mostly
I've created a complex search query in SQL 2008 that returns data sorted by
I'm looking for the best way to search a string of alphabetical characters for

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.