I want to maintain last ten years of stock market data in a single table. Certain analysis need only data of the last one month data. When I do this short term analysis it takes a long time to complete the operation.
To overcome this I created another table to hold current year data alone. When I perform the analysis from this table it 20 times faster than the previous one.
Now my question is:
- Is this the right way to have a separate table for this kind of problem. (Or we use separate database instead of table)
- If I have separate table Is there any way to update the secondary table automatically.
- Or we can use anything like dematerialized view or something like that to gain performance.
Note: I'm using Postgresql database.