For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the database). Is there any way for me to determine if it is going to finish in closer to 5 minutes, 5 hours, or 5 days?
Check the progress of the ALTER TABLE operation by querying the Performance Schema events_stages_current table. The stage event shown differs depending on which ALTER TABLE phase is currently in progress. The WORK_COMPLETED column shows the work completed.
If you have the general log enabled, simply do a grep -i "analyze table" against the general log file and locate the timestamp just about the command.
No, it shouldn't prevent the table from being altered. Though, if you drop the underlying table a view depends on, or alter/remove the columns from the table the view uses, the view can become invalid.
The first command you will need to use is the SELECT FROM MySQL statement that has the following syntax: SELECT * FROM table_name; This is a basic MySQL query which will tell the script to select all the records from the table_name table.
I was able to perform these 2 queries and figure out how many rows remain to be moved.
select count(*) from `myoriginalrable`; select count(*) from `#sql-1e8_11ae5`;
this was WAY more helpful than comparing the file size on disk, because changing from myisam to innodb etc changes the row size.
In the case of InnoDB tables, one can use SHOW ENGINE INNODB STATUS
to find the transaction doing the ALTER TABLE and check how many row locks the TX holds. This is the number of processed rows. Explained in detail here:
http://gabrielcain.com/blog/2009/08/05/mysql-alter-table-and-how-to-observe-progress/
Also MariaDB 5.3 and later has the feature to report progress for some operations (including ALTER TABLE). See:
http://kb.askmonty.org/en/progress-reporting/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With