I'm trying to alter a pretty large table (25GB including index) by adding a column & modifying an index, but in addition to taking a very long time (> 1 hour), which is ok, it affects the whole system, making queries on other tables more than 100 times slower, which is a huge issue and forced me to cancel the operation.
The server is pretty solid (196GB RAM with only 70GB used, SSD RAID disks with 300GB free space). Storage engine is MyISAM.
Is there any way to give the ALTER TABLE very low priority so that it doesn't dramatically affect the rest of the operations (I don't care if it takes twice the time)? Is it even normal that it does?
2 Answers 2
Use pt-online-schema-change. It will monitor server load and throttle itself if necessary.
-
Or github.com/github/gh-ost, github.com/soundcloud/lhmAlexey– Alexey2016年09月28日 02:19:39 +00:00Commented Sep 28, 2016 at 2:19
-
Never heard of ihn. Also pt-osc will refuse to alter if there are triggers in a table. Gh-ost is triggerlessakuzminsky– akuzminsky2016年09月28日 02:23:10 +00:00Commented Sep 28, 2016 at 2:23
-
LHM - it's ruby gem, uses triggers.Alexey– Alexey2016年09月28日 02:33:04 +00:00Commented Sep 28, 2016 at 2:33
-
Seems like a pretty handy tool, will take a look at it, thanks!Wuigi– Wuigi2016年09月28日 11:57:31 +00:00Commented Sep 28, 2016 at 11:57
Upgrade to InnoDB. Tips and caveats
Upgrade to at least 5.6
After those, you can do most ALTERs
with almost no downtime. See ALGORITHM=INPLACE
.
-
Thanks, useful link - unfortunately I can't switch engine for now, because of disk space among other thingsWuigi– Wuigi2016年09月28日 12:13:46 +00:00Commented Sep 28, 2016 at 12:13
-
A common space waster is using
BIGINT
(8 bytes) whenTINYTINT (1 byte) would suffice. And there are others. Let's see
SHOW CREATE TABLE`. How much RAM do you have?Rick James– Rick James2016年09月28日 15:08:02 +00:00Commented Sep 28, 2016 at 15:08
alter
ing process, do you write to this table, or only read? 2- Provideshow create table table_name
result please.