0

I am loading data from a file. MySQL doesn't seem to insert line by line. So how does mysql load the data. Does it do one big chunk at the end after reading the file? Reading a file with 50000 rows.

3
  • How can you tell how it's chunking it? Commented Apr 10, 2018 at 15:57
  • I am just guessing. I ran a load data infile command and would do a select on the table got nothing. Ran same select a minute later and got nothing. After the command was done running. ran the same select statment and data was there. So my guess is it chucking at the end. But have no clue. Commented Apr 10, 2018 at 16:57
  • It's doing it in a transaction. Commented Apr 10, 2018 at 17:09

1 Answer 1

3

If the table is InnoDB, each statement is executed as a transaction unless you start a transaction explicitly. So it's as if you'd written:

START TRANSACTION;
LOAD DATA INFILE ...;
COMMIT;

So the result of loading the file is made visible atomically.

See the documentation on autocommit mode.

Sign up to request clarification or add additional context in comments.

4 Comments

I just did [code]mysql --local-infile database [code]. The tablle is InnoDB and I get nothing until the table command finishes.
That makes it equivalent to LOAD DATA LOCAL INFILE ..., but it's still in a transaction.
BTW, use backticks in comments, not [code]foo[/code]
Thanks mysql --local-infile database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.