1
env: windows 10 
version mysql 5.7
Ram 32GB
ide : toad mysql

i have sufficient hardware requirement but issue is the performance of insert into simple table that does not have any relation ships. i need to have index on the table.

table structure

CREATE TABLE `2017` (
  `MOB_NO` bigint(20) DEFAULT NULL,
  `CAF_SLNO` varchar(50) DEFAULT NULL,
  `CNAME` varchar(58) DEFAULT NULL,
  `ACT_DATE` varchar(200) DEFAULT NULL,
  KEY `2017_index` (`MOB_NO`,`ACT_DATE`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I am using above for inserting the records into table. with out index it took around 30 min where as with indexing it took 22 hrs still going on.

SET autocommit=0;
SET unique_checks=0;
SET foreign_key_checks=0;
LOAD DATA LOCAL INFILE 'D:/base/test/2017/2017.txt' 
INTO TABLE 2017COLUMNS TERMINATED BY '|';
commit;

i have seen suggestion to change cnf file, Could not find any in my machine.

2 Answers2

1

By adding following lines in my.ini. I am able to achieve it.

innodb_autoinc_lock_mode =2
sync_binlog=1
bulk_insert_buffer_size=512M
key_buffer_size=512M
read_buffer = 50M

and innodb_flush_log_at_trx_commit=2, i have seen in another link where it said that it increase speed to 160x. Output performance :more than 24hr to 2 hrs

0

If you begin with an empty table, create it without any indexes. Then, after fully populating the table, adding an index is reported to be faster than inserting with the index already in place.

See:

Possibly helpful: Create an index on a huge MySQL production table without table locking

wallyk
  • 56,922
  • 16
  • 83
  • 148
  • I have tried few suggestion mentioned in other questions 1. Alter table after adding data 2 create table dump and then create index 3. Create table with index and dump data. 4 change in initiative file which worked for me as the insertion rate increased – raghavendra prasad gudipalli May 26 '18 at 19:21