Hello,
My application currently stores millions of Double
elements for a calculation. These values are only temporary values before they are used for a specific algorithm that is run at the end of the calculation. Once this calculation is done, the millions of values can be discarded.
The full story is here, if you need more details.
One of the solutions that was proposed is to use an in-memory database.
So if I go with this solution, I will use this database to store my values in a table to replace my current Map<String, List<Double>>
, like:
create table CALCULATION_RESULTS_XXX (
deal_id varchar2,
values number
);
(one table per calculation, XXX
is the calculation ID)
So during the calculation, I will do the following:
- When the calculation is started, I create the
CALCULATION_RESULTS_XXX
table. - Every time I need to add a value, I insert a record in this table.
- At the end of the calculation, I use the table content for my algorithm.
- Finally, I drop this table.
As explained in the other subject, currently, my calculation may store several hundreds of Mb of data in the memory, as a list of 30 * 1,000,000 of Double
will need about 240Mb.
The questions now:
- If I go with an in-memory database, does my memory consomption will be decreased?
- What are the specific points that I will have to take care regarding the database usage (or table creation), the data insertion, etc. ?
- I think I will choose H2 database. Do you think it's the best choice for my needs?