Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database cache 500 points

Posted on 2003-12-07
3
Medium Priority
?
182 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

705 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