mysql - Altering a Partitioned Table -


i can't find info online this.

what best way alter table partitioned?

should use normal

update `table` modify column `column_name` tinyint(1) default 1 not null; 

and lock table several minutes

or should run command partition partition?

update `table` partition (p0) modify column `column_name` tinyint(1) default 1 not null; 

what recommendations? happens if not partitions equal? possible?

this create statement:

create table `redirects` (    `emailhash` varchar(100) not null,    `f_email_log` varchar(50) not null,    `linknum` int(11) not null default '1',    `redirect` varchar(500) not null,    `clicked` int(11) not null default '0',    `clicktime` datetime not null default '0000-00-00 00:00:00',    primary key (`emailhash`),    key `f_email_log` (`f_email_log`)  ) engine=innodb default charset=utf8  /*!50100 partition key (emailhash)  partitions 16 */ 

the table has around 40 million records.

i want reduce size of fields int tinyint since values 1-30 or 0/1, varchar lengths since i've found number large , can reduced.

altering partitioned table requires altering each partition 1 @ time. meanwhile, entire table needs locked, otherwise, reads/writes stumble on half-finished alter.

please provide show create table, number of partitions, rationale partitioning @ all, , indicate column needs changing. may able suggest work-around.

more

400m rows 12gb schema?
4gb buffer_pool (which raised 11g ram)
md5 key
--> 67% of inserts , selects not find desired block in ram (cache), have hit disk. leads sluggish performance. worse table grows. , won't matter whether partitioned or not. (no cannot explain difference report.)

see here more discussion, no solution use case.

shrinking datatypes (4-byte int --> 1-byte tinyint unsigned, etc) some. unhex(md5) let put hash in 16 bytes: binary(16), thereby saving 18 bytes on have now. shrinking max on varchar has little or no effect. ditto character set.

the query need where emailhash=unhex('abcdef1234567890')

alter

back original question of how alter "fast". unless already have replication set up, out of luck. partitions must have same schema, idea altering them one-by-one not possible.

but... check pt-online-schema-change , gh-ost see if work partitioned tables.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -