I have a database with a huge table, that gathers the ranking history of mobile applications. The table is quite big, around 120 Go. In order for my DB queries not to be too slow, I implemented several materialized views. One of these materialized calculates the average rankings of apps over the last 30 days. It is refreshed everyday.
I now want to be able to tell at any point in time what that average was on a particular date. I.e, to have an history of averages.
Would it make sense to add the results of my materialized view everyday to a table ? Or should I partition that big table and do it another way ?
Edit : Main table structure (738,681,765 rows)
+----+--------+---------+------+-------+---------------+------------+-------------+
| id | app_id | ranking | date | price | collection_id | country_id | category_id |
+----+--------+---------+------+-------+---------------+------------+-------------+
| 1 | 1426 | 30 | t1 | 0 | 12451 | 1658 | 2564 |
| 2 | 1427 | 15 | t2 | 0 | 23562 | 1485 | 3256 |
| 3 | 1428 | 22 | t3 | 0 | 14564 | 1320 | 4521 |
| 4 | 1429 | 11 | t4 | 0 | 12468 | 1578 | 5015 |
| 5 | 1430 | 10 | t5 | 0 | 18712 | 1100 | 6012 |
+----+--------+---------+------+-------+---------------+------------+-------------+
t1
,t2
? Is it a date or timestamp? How many days of history will you keep? How much history does it cover in 738,681,765 rows? Also, with big tables it is usually enough that indexes and dictionaries fit in RAM. So, your 32GB might be well enough - depending on application.