How to load data to MySQL faster?

4

I have a DER that represents an airport and I have to load data from several csv there. for example I have a connection from 1 to many, from airline to flights. If I have this table linked with the foreign key it gives me error loading data so I have not inserted any links. So I'm doing it for joins. I'm doing the following query:

Use tese;
create table aviao1 
(select a.tailnum, a.type, a.manufacturer, a.issue_data, a.model, a.status, a.aircraft_type, a.engine_type, a.year, c.uniquecarrier 

From aviao a

INNER JOIN voos c

ON a.tailnum = c.tailnum )

The tail number is my primary key in the plane table and the flight table is my foreign key. Both are contained in the csv airplane and flight. So I see which ones correspond and I create a new plane table with the keys that match. The problem is when I go to make the appointment, it's been more than 9 hours to run and it's not over yet. Is it normal to take so much time or is there a way to make this process faster?

    
asked by anonymous 15.09.2015 / 03:56

1 answer

1

The load data infile command loads data from a CSV file very quickly. Because you have foreign keys, you can turn off the check before executing the command and then reconnect later. It would look something like:

SET foreign_key_checks = 0; 
LOAD DATA INFILE ... ; 
SET foreign_key_checks = 1;
    
02.10.2015 / 23:18