最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

WhyALTERTABLErunsfasteronPerconaServer5.5vs.MySQL_MySQL

来源:动视网 责编:小采 时间:2020-11-09 19:17:40
文档

WhyALTERTABLErunsfasteronPerconaServer5.5vs.MySQL_MySQL

WhyALTERTABLErunsfasteronPerconaServer5.5vs.MySQL_MySQL:Some of us Perconians are atOpenStack summitthis week in Atlanta.Matt Griffin, our director of product management,tweetedabout the turbo-hipster CI talk about their experience of ALTER TABLEs running faster on Percona Server. Oracles Morga
推荐度:
导读WhyALTERTABLErunsfasteronPerconaServer5.5vs.MySQL_MySQL:Some of us Perconians are atOpenStack summitthis week in Atlanta.Matt Griffin, our director of product management,tweetedabout the turbo-hipster CI talk about their experience of ALTER TABLEs running faster on Percona Server. Oracles Morga
 Some of us Perconians are atOpenStack summitthis week in Atlanta.Matt Griffin, our director of product management,tweetedabout the turbo-hipster CI talk about their experience of ALTER TABLEs running faster on Percona Server. Oracle’s Morgan Tockerthentweeted in response, asking why this was the case. I decided that the simplest way to answer that was here in this post.

The reason for this is the expand_fast_index_creation feature of Percona Server. I did a quick schema change on MySQL 5.5 and Percona Server 5.5 to demonstrate this(in the talk, the speaker mentioned that these versions were used).

The schema modifications in the talk could fall in 2 categories, the ones that could use fast index creation and the ones that could not.

I did the following tests on my laptop, on a sysbench tale with 300k records.

Vanilla MySQL 5.5:

mysql> alter table sbtest1 add index idx_c(c);Query OK, 0 rows affected (4.37 sec)

mysql>altertablesbtest1addindexidx_c(c);

QueryOK,0rowsaffected(4.37sec)

Percona Server 5.5:

mysql> alter table sbtest1 add index idx_c(c);Query OK, 0 rows affected (3.90 sec)

mysql>altertablesbtest1addindexidx_c(c);

QueryOK,0rowsaffected(3.90sec)

We know that this used fast index creation from the 0 rows affected. In this case, there is nor substantial difference between the 2 servers, also probably my laptop with CPU frewquency scaling doesn’t have the most consistent performance in the world.

For the second schema change, I added a column which copies the table.

Vanilla MySQL 5.5:

mysql> alter table sbtest1 add column d int default 0;Query OK, 300000 rows affected (37.05 sec)Records: 300000Duplicates: 0Warnings: 0

mysql>altertablesbtest1addcolumndintdefault0;

QueryOK,300000rowsaffected(37.05sec)

Records:300000 Duplicates:0 Warnings:0

Percona Server 5.5:

mysql> alter table sbtest1 add column d int default 0;Query OK, 300000 rows affected (9.51 sec)Records: 300000Duplicates: 0Warnings: 0

mysql>altertablesbtest1addcolumndintdefault0;

QueryOK,300000rowsaffected(9.51sec)

Records:300000 Duplicates:0 Warnings:0

The reason for this speed difference is that in case of Percona Server, for the table copy, the table is created only with a primary key, and the secondary indexes are built at the end of the process (rather than on the fly). For more details, checkAlexey’s blog poston this topic.

This can be tuned further, by tuning innodb_merge_sort_block_size (in Percona Server 5.6, this is replaced by innodb_sort_buffer_size).

mysql> select @@innodb_merge_sort_block_size/1024/1024;+------------------------------------------+| @@innodb_merge_sort_block_size/1024/1024 |+------------------------------------------+| 1.00000000 |+------------------------------------------+1 row in set (0.00 sec)mysql> set innodb_merge_sort_block_size=8*1024*1024;Query OK, 0 rows affected (0.00 sec)mysql> alter table sbtest1 add column d int default 0;Query OK, 300000 rows affected (8.61 sec)Records: 300000Duplicates: 0Warnings: 0

mysql>select@@innodb_merge_sort_block_size/1024/1024;

+------------------------------------------+

|@@innodb_merge_sort_block_size/1024/1024|

+------------------------------------------+

| 1.00000000|

+------------------------------------------+

1rowinset(0.00sec)

mysql>setinnodb_merge_sort_block_size=8*1024*1024;

QueryOK,0rowsaffected(0.00sec)

mysql>altertablesbtest1addcolumndintdefault0;

QueryOK,300000rowsaffected(8.61sec)

Records:300000 Duplicates:0 Warnings:0

So, in order to be accurate, schema changes are faster in Percona Server if they are table copies and if the tables have secondary indexes.

文档

WhyALTERTABLErunsfasteronPerconaServer5.5vs.MySQL_MySQL

WhyALTERTABLErunsfasteronPerconaServer5.5vs.MySQL_MySQL:Some of us Perconians are atOpenStack summitthis week in Atlanta.Matt Griffin, our director of product management,tweetedabout the turbo-hipster CI talk about their experience of ALTER TABLEs running faster on Percona Server. Oracles Morga
推荐度:
标签: 5.5 mysql run
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top