Solved

Database cache 500 points

Posted on 2003-12-07
3
178 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
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

773 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