MySQL Forums
Forum List  »  Performance

Re: INSERT IGNORE ... SELECT performance question
Posted by: Rick James
Date: July 23, 2011 04:59PM

1. Let's see SHOW CREATE TABLE Move
The indexing of it may help, or hurt.

2. Let's see EXPLAIN SELECT NULL,fenbefore,fenafter,position FROM move
to see how it is doing the query.

3. Perhaps your key_buffer is tiny.
http://mysql.rjweb.org/doc.php/memory

4. It _may_ be that this would run faster:
INSERT IGNORE INTO positions
SELECT NULL,fenbefore,fenafter,position
FROM move
ORDER BY fenbefore,fenafter,position;

Some of the rationale...
To do the INSERT, each row must be checked for duplicate keys. The PRIMARY KEY is an AUTO_INCREMENT, hence, no problem. The UNIQUE key is probably why it is taking so long. If (and this is a big if) doing a sort first (suggestion #4) is more efficient, then the rows will simply slide into place with essentially no effort.

5. Possibly an improvement over #4:
INSERT INTO positions
SELECT DISTINCT NULL,fenbefore,fenafter,position
FROM move;

6. InnoDB indexing is inherently more efficient for mapping tables (such as this). You could try that engine. (Recommend using flavor #5.) However, if you end up mixing engines, see my doc about the setting for innodb_buffer_pool_size.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: INSERT IGNORE ... SELECT performance question
2710
July 23, 2011 04:59PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.