i have an application written in Play Framework 1.2.5 and i am using H2 File as database.
The application has a “Sales” Table that gets about 1000 rows per day. i have about 5 years of data in it (usually 2-3 years data will be available) so basically i have a table with 1.5Mil+ data in my test machine.
My problem is, the client asks for data like “give me the sum os sales between dates and group bu product type and sales type”. So i have to make somehing like a select query with 2 groups and date range.
As the table grows larger, the select query performance is decreasing dramatically. What can i do to get better results?
I have created another table with summarized sales like hourly, daily and monthly, but there are functions that i mush search from the sales table.
the first application was written in c# (asp.net webservice) and ms-sql server with stored procedures as database, these operationg were quick as few seconds top. and i had the same about of data, even i wasnt using any summarized table the make queries quicker.
I know, a dedicated server application will always be faster than an embedded server, but i think there must be a way to improve the performance of this query.
Is there any optimizations that i can do over H2 engine.
Becuase of concurrency issues, i had to enable “MVCC” on H2 server, could this be a problem on performance?
Thanks for reaindg and spending your time.
**Edit For people who use Play Framework 1.2.x:
i’ve just added @Index(name=”sales_columnname_index”) annotation on each column i want to add to index and now H2 engine is working even faster than my old mssql+asp.net application.
You have to do the optimizations by creating the correct indexes.
For example for this
you need an index (not necessarily unique) over the columns product type, sales type and time, like this:
In your HQL query you have to mention the index columns in a way to make sure the database uses this index, for example
or
In the second example then you have to sum up the mounts in your Java code.