简体   繁体   English

mysql / innodb数据库大小如何影响性能?

[英]How mysql/innodb database size impacts performance?

I have a 30 GB large mysql database where all tables use innodb engine. 我有一个30 GB的大型mysql数据库,其中所有表都使用innodb引擎。 Almost all of this space is taken by one large table (about 25 GB) where I store large texts in binary format, but 99% of the queries use other, smaller, tables. 几乎所有这些空间都由一个大表(大约25 GB)占用,我以二进制格式存储大文本,但是99%的查询使用其他较小的表。

My server has 16 GB ram and system is very short on memory, always uses swap and gives my users a lot of pain. 我的服务器有16 GB的内存,系统内存非常不足,总是使用swap,这给我的用户带来很多麻烦。 I have my innodb_pool_buffer_size set to 6G . 我的innodb_pool_buffer_size设置为6G

I am thinking of solving this performance problem by moving those texts from database to filesystem. 我正在考虑通过将这些文本从数据库移动到文件系统来解决此性能问题。

Will moving 25 GB of texts to filesystem solve this problem, if most queries do not use this large table? 如果大多数查询不使用此大表,将25 GB的文本移到文件系统是否可以解决此问题? Does database size impacts server performance even if largest innodb table is not used for queries too much? 即使最大的innodb表没有过多地用于查询,数据库大小也会影响服务器性能吗?

There's simply not enough information in your question to provide an answer. 您的问题中没有足够的信息来提供答案。

Before applying possible solutions to your problem, you need to take a systematic approach to find the problem . 在为问题应用可能的解决方案之前,您需要采取系统的方法来发现问题 Otherwise, you're prescribing random drugs, for an unknown ailment. 否则,您将开处方随机药物,以治疗未知疾病。 You're as likely to make the problem worse as you are to make it better, or have no effect. 使问题变得更糟的程度与使问题变得更好或没有效果的可能性一样大。

Start by running EXPLAIN on your slow queries, to see what they're doing. 首先对缓慢的查询运行EXPLAIN ,以查看它们在做什么。 Make sure you have your table(s) properly indexed to improve those queries (if they aren't already). 确保您的表已正确索引以改善这些查询(如果尚未进行)。 And then, if you're still stuck, post your slowest query, and the output of EXPLAIN as a new question here, and you'll get much more useful answers. 然后,如果您仍然遇到问题,请在此处发布最慢的查询以及EXPLAIN的输出作为新问题,您将获得更多有用的答案。

I completely agree with Flimzy that you will need to closer inspect how your database is being used and, if you need help with optimizing it, you will need more information. 我完全同意Flimzy的观点,您将需要仔细检查数据库的使用方式,如果需要优化数据库的帮助,则需要更多信息。

However, I can answer you the two questions you asked. 但是,我可以回答您两个问题。 In 99.9% of the cases, moving to a filebased system is NOT better than MySQL. 在99.9%的情况下,迁移到基于文件的系统并不比MySQL更好。 MySQL has a MUCH better approach to sorting, ordering and selecting data that a standard file system. MySQL具有比标准文件系统更好的方法来对数据进行排序,排序和选择。 Basically, any OS is really bad at maintaining large quantities of files in a single directory and I/O and latency times of your HDD will simply go through the roof. 基本上,任何操作系统都很难在单个目录中维护大量文件,并且HDD的I / O和延迟时间将很快消失。
And to the second questions: No, database/table size does not have to impact server performance. 第二个问题是:不,数据库/表的大小不必影响服务器性能。 I have a 145 GiB InnoDB table (granted, it is on an SSD) and it is being used severely, without my site taking a big hit. 我有一个145 GiB InnoDB表(允许,它在SSD上),并且在我的网站没有受到太大影响的情况下,它被严重使用。 :ole Flimzy said, you will have to optimize your SQL server, table design and indexing, and then queries for optimum performance. :ole Flimzy说,您将必须优化SQL Server,表设计和索引编制,然后查询以获得最佳性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM