View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 10:28 AM
John Nagle
 
Posts: n/a
Default Re: How long does indexing via ALTER TABLE take?

Brian Wakem wrote:
> John Nagle wrote:
>
>
>> I loaded about 15 million records into a MySQL table, and
>>then did an ALTER TABLE to add an index on a BIGINT field.
>>The ALTER TABLE has been running for about 30 hours now.
>>About how long should that take?

>
>
>
> I would say 3-20 minutes depending on the hardware, so long as box is doing
> nothing else.
>
> What does SHOW PROCESSLIST say?
>


+-------+-----------+-----------+-----------+---------+-------+----------------------+------------------------------------------+
| Id | User | Host | db | Command | Time | State
| Info |
+-------+-----------+-----------+-----------+---------+-------+----------------------+------------------------------------------+
| 38101 | sitetruth | localhost | sitetruth | Query | 85334 | Repair with
keycache | alter table infotus add primary key (id) |
| 38268 | sitetruth | localhost | NULL | Query | 0 | NULL
| show processlist |
+-------+-----------+-----------+-----------+---------+-------+----------------------+------------------------------------------+
2 rows in set (0.04 sec)

It's been running for about 30 hours now, on an otherwise-idle dedicated
server. MySQL 5 on Fedora Core 6, default Plesk installation.

-bash-3.1$ ps ax
PID TTY STAT TIME COMMAND
1793 ? S 0:00 /bin/sh /usr/bin/mysqld_safe
--defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid
--log-error=/var/log/mysqld.log
1829 ? Sl 541:14 /usr/libexec/mysqld --defaults-file=/etc/my.cnf
--basedir=/usr --datadir=/var/lib/mysql --user=mysql
--pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking
--socket=/var/lib/mysql/mysql.sock

It's continuing to use CPU time, and the MySQL server is responding properly
to other requests. The "Time" value in SHOW PROCESSLIST continues to go up.

John Nagle
Reply With Quote