Algorithmically, it is doing what your colleague says. But, do you see what it is doing ???
It is generating 10,000 temp tables each containing 1 row after traversing 317 million rows through in the InnoDB internal index. Each temp table is a complete regeneration of the rowids in sernumbers_results_2009 table along with executing handler_read_prev commands internally to sort the data by an index scan from the back of the internal rowid index. Also, please remember you are dealing with InnoDB. Who knows what Multiversioning (via MVCC) is going on so that the INSERT is completed without interference and with rollback capabilities.
Is there any reason why this query wouldn't work for you ???
INSERT INTO sernumbers_results_2009
SELECT * FROM sernumbers_results
ORDER BY rowid DESC LIMIT 10000;
This will definitely generate one temp table.
Give it a Try !!!
Surprisingly, that's not gibberish.
That indeed appears at the top of binlogs whenever you do mysqlbinlog to a binary log generated using MySQL 5.1 and MySQL 5.5. You will not see that gibberish in binary logs for MySQL 5.0 and back.
This is why the start point for replication from an empty binary log is
- 107 for MySQL 5.5
- 106 for MySQL 5.1
- 98 for MySQL 5.0 and back
This is good to remember if you do MySQL Replication where the Master if MySQL 5.1 and the slave is MySQL 5.0. This could present a really big headache.
Replication from Master using 5.0 and Slave using 5.1 works fine, not the other way around.(According to MySQL Documentation, it is generally not supported for 3 reasons: 1) Binary Log Format, 2) Row-based Replication, 3) SQL Incompatibility).
Anyway, do a mysqlbinlog on the offending binary log on the master. If the resulting dump produces gibberish in the middle of the dump (which I have seen a couple of times in my DBA career) you may have to skip to position 98 (MySQL 5.0) or 106 (MySQL 5.1) or 107 (MySQL 5.5) of the master's next binary log and start replicating from there (SOB :( you may need to use MAATKIT tools mk-table-checksum and mk-table-sync to reload master changes not on the slave [if you want to be a hero]; even worse, mysqldump the master and reload the slave and start replication totally over [if you don't want to be a hero])
If the mysqlbinlog of the master is completely readable after the top gibberish you saw, it is possible the master's binary log is fine but the relay log on the slave is corrupt (due to transmission/CRC errors). If that's the case, just reload the relay logs by issuing the CHANGE MASTER TO command as follows:
STOP SLAVE;
CHANGE MASTER TO
MASTER_HOST='< master-host ip or DNS >',
MASTER_PORT=3306,
MASTER_USER='< usernmae >',
MASTER_PASSWORD='< password >',
MASTER_LOG_FILE='< MMMM >',
MASTER_LOG_POS=< PPPP >;
START SLAVE;
Where
- MMMM is the last file used from the Master that was last processed on the Slave
- PPPP is the last position used from the Master that was last processed on the Slave
You can get MMMM and PPPP by doing SHOW SLAVE STATUS\G
and using
- Relay_Master_Log_File for MMMM
- Exec_Master_Log_Pos for PPPP
Try it out and let me know !!!
BTW running CHANGE MASTER TO command erases the slave's current relay logs and starts fresh.
Best Answer
There are three(3) aspects you need to consider
ASPECT #1
You may find this astonishing but did you know that some older versions of MySQL can outperform newer versions ? You must tune MySQL 5.5 properly. In fact, InnoDB has new options introduced into the InnoDB Plugin.
I have earlier articles in the StackExchange on this
Jul 16, 2012
: decreased performance of stored procedure when migrated from mysql server 5.0 to 5.5Feb 22, 2012
: MySQL 5.1 vs MySQL 5.5 (5.1 twice as fast)Nov 24, 2011
: Why mysql 5.5 slower than 5.1 (linux,using mysqlslap)Jun 19, 2011
: How do I properly perform a MySQL bake-off?ASPECT #2
Looking at the my.ini, something caught my attention: you have
innodb_thread_concurrency=10
. That's a definite no-no, especially with MySQL 5.5. I say this because MySQL 5.x thrives on setting the innodb_thread_concurrency to 0. At Percona Live NYC 2011, Ronald Bradford explicit told me as I sat in the audience not to set this to any other value than 0. By setting it to zero, it lets InnoDB figure out the correct number of threads it needs create.ASPECT #3
You need to activate multiple cores for InnoDB. MySQL 5.0/5.1 are not designed to use multiple cores. The InnoDB Plugin (from MySQL 5.1.38 has new options for doing so. Those options are fully present in MySQL 5.5. Such include