- I am a college undergrad working on a PHP and MySQL based inventory management system operating on a country-wide level. Its database size is projected to increase by about 1 million plus entries every month with current size of about 2 million.
I need to prevent the exponential increase in query time which is currently ranges from 7-11 seconds for most modules.
The thing is that the probability of accessing data entered in the last month is much higher as compared to any older data. So I believe partitioning of data on the basis of time of data entry should be able to keep the query time in check. So how can I achieve this.
Specifically speaking I want to have a way to cache the last month's data so that every query searches for the product in the tables having recent data and should search rest of the data in case it is not found in the last 1 month's data.
user1593979
问问题
428 次
1 回答
0
如果你想使用 MySQL 的分区功能,看看这篇文章。
话虽如此,使用分区时有一些限制:
- 你不能有不在分区键中的索引
- 您失去了一些数据库的可移植性,因为分区与其他数据库的工作方式完全不同。
您还可以通过定期将旧记录移动到存档表来手动处理分区。当然,您还必须实现不同的代码来读取这些归档记录。
另请注意,您的查询时间似乎很长。我使用的表比 200 万条记录大得多,访问时间要好得多。
于 2012-08-12T21:58:03.427 回答