Mukesh Swami
Mukesh Swami

Reputation: 415

Importing millions no of records from text file to mysql table

I need to insert records in MYSQL from a text file, that's not a problem.

The problem is that the text file contains millions of record. This means that processing one text file would results into millions of INSERT query. Also I can't (don't want to) use PHP Infile as I have to perform some data extraction on the text file. Storing that file into a Blob field this is not what I am looking.

Upvotes: 0

Views: 735

Answers (1)

Sabeen Malik
Sabeen Malik

Reputation: 10880

Instead of individual INSERTs use bulk INSERTs like

INSERT INTO a VALUES (1,23),(2,34),(4,33);

Might be worth looking at this question.

Keep in mind that you might hit the packet size limit, look at this question for pointers.

Upvotes: 1

Related Questions