MySQL数据库在什么时候开始失去性能?

物理数据库大小重要吗? 记录的数量重要吗? 性能下降是线性的还是指数级的?

我有一个我相信是一个大的数据库,大约有1500万条记录,占用了近2GB。基于这些数字,我是否有任何动机清理数据,或者我是否可以允许它继续扩展几年?


当前回答

如果数据库设计不当,性能可能会在几千行中下降。

如果你有合适的索引,使用合适的引擎(不要使用MyISAM,因为需要多个dml),使用分区,根据使用情况分配正确的内存,当然还有良好的服务器配置,MySQL可以处理tb级的数据!

总有办法提高数据库性能。

其他回答

物理数据库大小无关紧要。记录的数量并不重要。

In my experience the biggest problem that you are going to run in to is not size, but the number of queries you can handle at a time. Most likely you are going to have to move to a master/slave configuration so that the read queries can run against the slaves and the write queries run against the master. However if you are not ready for this yet, you can always tweak your indexes for the queries you are running to speed up the response times. Also there is a lot of tweaking you can do to the network stack and kernel in Linux that will help.

我的内存达到了10GB,只有中等数量的连接,它处理请求还不错。

我将首先关注您的索引,然后让服务器管理员查看您的操作系统,如果所有这些都没有帮助,那么可能是时候实现主/从配置了。

总的来说,这是一个非常微妙的问题,无论如何都不是微不足道的。我建议你阅读mysqlperformanceblog.com和高性能MySQL。我真的认为这个问题没有普遍的答案。

我正在做一个项目,它有一个MySQL数据库,几乎有1TB的数据。最重要的可伸缩性因素是RAM。如果您的表的索引适合内存,并且您的查询得到了高度优化,那么您可以使用普通机器处理合理数量的请求。

记录的数量确实很重要,这取决于表的外观。有很多varchar字段和只有几个int或long类型是有区别的。

数据库的物理大小也很重要:例如,考虑备份。根据你的引擎,你的物理db文件会增长,但不会缩小,例如innodb。因此,删除大量的行,并不有助于缩小您的物理文件。

这个问题有很多,在很多情况下,细节决定成败。

还要注意复杂连接。除了交易量之外,交易复杂性也是一个很大的因素。

重构繁重的查询有时会大大提高性能。

I once was called upon to look at a mysql that had "stopped working". I discovered that the DB files were residing on a Network Appliance filer mounted with NFS2 and with a maximum file size of 2GB. And sure enough, the table that had stopped accepting transactions was exactly 2GB on disk. But with regards to the performance curve I'm told that it was working like a champ right up until it didn't work at all! This experience always serves for me as a nice reminder that there're always dimensions above and below the one you naturally suspect.

谈论“数据库性能”有点毫无意义,“查询性能”在这里是一个更好的术语。答案是:这取决于查询,它所操作的数据,索引,硬件等。您可以了解将要扫描多少行,以及使用EXPLAIN语法将使用哪些索引。

2GB并不算真正的“大”数据库——它更像是一个中等大小的数据库。