Solved

Database cache 500 points

Posted on 2003-12-07
3
181 Views
Last Modified: 2010-04-02
Hi Experts!

I want to cache a recordset of 500,000 records with 7 fields in it (date, stock, open, high, low, close, volume).  Assume the first field is the date, and the second field is a stock.

I was thinking I could put them into an array.  However I am worried that I will not be able to sort these records effieciently.  Like if I wanted to find IBM from 1-1-01 to 1-1-02.  Or if i wanted to all stocks and their respective prices on 1-1-01.  

I know this has been done before and I dont want to reinvent the wheel here.  What is the best way to cache all this info into memery, and still have the functionality of doing simple select queries?

Thanks for your help!


0
Comment
Question by:OptionsMM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 9894896
The right solution is to have multiple indexes for your database.
Each field that you need to look-up, have it set as an index in your database table.

Your database then should be able to query the information quickly.

What database are you using?
0
 

Author Comment

by:OptionsMM
ID: 9983071
I am not interested in indices (it is only one large table).
Can I cache the whole table using arrays?


0
 
LVL 30

Accepted Solution

by:
Axter earned 500 total points
ID: 9983282
>>I am not interested in indices (it is only one large table).
>>Can I cache the whole table using arrays?

If you have the RAM, yes.
But accessing the data would not be as efficient as it would be if you indexed the table.

You don't need multiple talbes to justify indexing a table.
Many databases only have one table and multiple indexes associated with the one table.

An index is a method that allows you to access a record in the table very fast using a field other then the primary filed.

If you want to put the record into RAM you can use a vector<> template class, however you're going to need a lot of RAM to hold 500,000.  And this method will still not access the data quickly.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question