Solved

Database cache 500 points

Posted on 2003-12-07
3
177 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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now