Domanda

I am using EasyPHP 12.1 with MySQL on an old Windows XP system. I have a SQL script (script.sql) with < 10 table creations and > 200,000 INSERT INTO statements. The script is structured like this:

SET autocommit = 0;
START TRANSACTION;
USE myDatabase;
...
COMMIT;

Where ... is the body of the script, most of which are inserts.

I'm running this with mysql -uuser -ppassword < script.sql.

When I do this, it takes well over an hour to insert ~ 1/3 of the records. This can't be right, so I must be doing something wrong -- but what? Can you see any problems with this script? Are there any known bugs or performance issues with this stack?

È stato utile?

Soluzione

There is one thing that did not transpire in the comments. A storage engine affects where the data is stored. This also affects how it is stored, which leads to MyISAM being slower than innoDB on INSERT (due to myISAM requiring a full index re-write on every insertion).

If you are using the MEMORY engine, consider changing. MEMORY is good for temporary tables - the moment you shut down your server, you'll lose the contents of the tables. MEMORY should NEVER be used for permanent tables.

Consider InnoDB, MyISAM, or ARCHIVE if your data is not indexed. This will create significantly higher first-creation times (due to the fact that, unlike MEMORY, both MyISAM, INNODB and ARCHIVE have to write to disk and regenerate indices), but it'll at least mean that your tables will not miraculously disappear the moment you shut the server down.

I'd strongly recommend reading up on the various storage engines, as it is pretty crucial in most cases. There are some very, very cool features in them, too.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top