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.
-
How can you tell how it's chunking it?Barmar– Barmar2018-04-10 15:57:42 +00:00Commented 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.user3525290– user35252902018-04-10 16:57:16 +00:00Commented Apr 10, 2018 at 16:57
-
It's doing it in a transaction.Barmar– Barmar2018-04-10 17:09:47 +00:00Commented Apr 10, 2018 at 17:09
Add a comment
|
1 Answer
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.
4 Comments
user3525290
I just did [code]mysql --local-infile database [code]. The tablle is InnoDB and I get nothing until the table command finishes.
Barmar
That makes it equivalent to
LOAD DATA LOCAL INFILE ..., but it's still in a transaction.Barmar
BTW, use backticks in comments, not [code]foo[/code]
user3525290
Thanks
mysql --local-infile database