简体   繁体   English

制作表innodb和分区会提高mysql的性能吗?

[英]Will making a table innodb and partitioning improve performance in mysql?

I have a Myisam table with composite unique key of 2 columns and 90 million data. 我有一个Myisam表,其中包含2列和9千万数据的复合唯一键。 Now we are facing memory and load issues and after going through the web I am planning to include partitioning and changing this table to Innodb for better performance. 现在我们正面临内存和负载问题,在浏览完网络后,我计划将分区和更改此表更改为Innodb以获得更好的性能。 But I have following concerns: 但我有以下担忧:

  1. Changing to innodb will have a huge downtime, Is it possible to minimize the downtime? 改用innodb将会有很长的停机时间,是否可以最大限度地减少停机时间?

  2. Most of the select query are on a particular column of the key on which I am planning to have the hash partitioning, how much it will effect the query on another key column? 大多数select查询都在我计划进行哈希分区的键的特定列上,它会对另一个键列的查询产生多大影响?

Will these changes improve the performance to the extent mentioned theoretically? 这些变化是否会在理论上提升到性能? Is there any better solution for such cases. 这种情况有没有更好的解决方案。 Any suggestion or experience can be helpful. 任何建议或经验都会有所帮助。

My queries are simple like 我的疑问很简单

Select * from Table where Col1= "Value"
Select * from Table where Col1="Value" and Col2 IN (V1,V2,V3)

Inserts are very frequently. 插入是非常频繁的。

InnoDB will probably help some. InnoDB 可能会帮助一些人。 Conversion to InnoDB comes with some issues, as I state in My conversion blog . 转换到InnoDB会带来一些问题,正如我在My conversion blog中所述

Partitioning, per se, buys no performance gain. 分区本身不会带来性能提升。 My partitioning blog lists 4 cases where you can, with design changes, gain performance. 我的分区博客列出了4种情况,您可以通过设计更改获得性能。

Regardless of the Engine, your two queries will both benefit from 不管发动机,你的两个查询将受益

INDEX(col1, col2)

No form of partitioning will help. 没有任何形式的分区会有所帮助。 HASH partitioning is especially useless. HASH分区尤其无用。

Conversion to InnoDB will take a lot of downtime, unless pt-online-schema-change will work for your case. 转换到InnoDB将需要大量的停机时间,除非pt-online-schema-change适用于您的情况。 Research it. 研究它。

Also read my answers and comments on Can i set up Mysql to auto-partition? 另请阅读我的答案评论我可以将Mysql设置为自动分区吗? for more specifics. 更多具体细节。

It may be that adding that index is the main performance gain. 可能是添加该索引是主要的性能增益。 But you have to do a lengthy ALTER to get it. 但是,你必须做一个漫长的ALTER得到它。 MyISAM does not have ALGORITHM=INPLACE . MyISAM没有ALGORITHM=INPLACE

Innodb (about perfomance we are talking now) have sense only when there are alot of inserts and updates to your table, because of row-locking table. Innodb(我们现在谈论的性能)只有当你的表有很多插入和更新时才有意义,因为行锁定表。 If the most queries on your table are SELECTs then MyIsam will be faster. 如果您桌面上的大多数查询都是SELECT,那么MyIsam会更快。 Advice: put in my.cnf key_buffer_size equal to 25% of your free RAM. 建议:放入my.cnf key_buffer_size等于你可用内存的25%。

If inserts on your database are very frequent, you will likely gain performance by switching to innodb, which won't lock down entire tables to insert, allowing other clients to select data concurrently. 如果数据库上的插入非常频繁,您可能会通过切换到innodb获得性能,而innodb不会锁定整个表以插入,允许其他客户端同时选择数据。

Regarding question #1, if you are worried about downtime, I'd suggest you find a parallel dump/load solution for migrating your data to innodb. 关于问题#1,如果您担心停机时间,我建议您找到一个并行转储/加载解决方案,用于将数据迁移到innodb。 if you simply run an ALTER statement on your tables, this is a single threaded operation which will be much slower. 如果你只是在表上运行一个ALTER语句,这是一个单线程操作会慢得多。

Regarding #2, you'd have to post a schema along with your partitioning strategy and the queries you are worried about. 关于#2,您必须发布架构以及您的分区策略和您担心的查询。

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

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