Reputation: 7653
I just exported a 150 MB table using mysqldump from command line. It took about 5 seconds to export it.
However when I try to import the same file it takes up to 5 minutes.
Why is import slower than export and is there a way to speed it up? I need to export/import tables that are greater than 1 GB.
Does it have to do something with locks? Since select is reading data therefore exporting it would be faster and import is writing data and could be slower since it needs write locks.
Upvotes: 0
Views: 1172
Reputation: 753900
Reading is a lot simpler than writing in the DBMS. And that's before you consider transaction logging. For instance, you have to write the row of data; you also have to update all the indexes on the table where the new row is. That means there's a lot more than a single I/O per written record.
Upvotes: 1
Reputation: 310909
Writing is slower than reading, on almost any medium. In a DBMS, indexes have to be maintained, constraints have to be checked, space has to be allocated, transaction boundaries have to be oberved, transaction loggging has to happen so that rollbacks will work, ...
Upvotes: 1