I'm puzzled with my SQL homework. I'm not an expert in databases. I'm using MySQL.
I have a table named 'news'
create table news
title text not null,
time DATE,
ip varchar(15),
reporter varchar(25),
tag varchar(20),
id int not null auto_increment,
primary key(id)
)engine=innodb;
And I have a txt file 'news2.txt' with 1000000 lines of data.
I want to optimize my sql for speed.
Here is my SQL statement
SET UNIQUE_CHECKS=0;
SET AUTOCOMMIT=0;
load data local infile "e:/news2.txt" into table news fields terminated by ',' LINES TERMINATED BY '\n' (title,time,ip,reporter,tag);
SET UNIQUE_CHECKS=1;
SET AUTOCOMMIT=1;
the 'news2.txt' contains like*'Vivamus dictum ultrices Curae aliquet vel nunc Aenean,2013/10/8,10.0.0.252,Reed Wyatt,Science'* it's a row.
The execution time is 29.188s. Are there any problems with my table design? What can I do to make it faster?
Copyright Notice:Content Author:「Peter Guan」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19763232/optimizing-mysql-or-table-design