Jump to content

1 million insert queries


scarhand

Recommended Posts

Just make sure you don't get max execution time errors.  Besides that, you should be prepared for it to potentially take a while.

 

If it's MySQL, I would insert mutliple values at a time (I would probably do blocks of 250, maybe more or less depending on the server).

 

Ex:

 

INSERT INTO tbl VALUES ('value1'), ('value2')

 

That would make 2 rows.

Link to comment
Share on other sites

If you have the data already in a file, do not use INSERT but rather LOAD DATA INFILE.

 

The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed.

 

FYI: The other day, I had to do 6,000 inserts in a MySQL InnoDB table on our production server (with live users active) and it took 4 minutes.

 

 

Link to comment
Share on other sites

That's still a lot of rows. You know your data best and what you're trying to do, however, you have not really shared why you think you need to do a loop?

 

FYI: There are some things that you can dynamically do with the load data infile (like assign variables and do calculations before data is inserted).

 

Good luck to you.

 

 

Link to comment
Share on other sites

That's still a lot of rows. You know your data best and what you're trying to do, however, you have not really shared why you think you need to do a loop?

 

FYI: There are some things that you can dynamically do with the load data infile (like assign variables and do calculations before data is inserted).

 

Good luck to you.

 

 

 

im taking content from static pages and inserting it into a database so it can be edited through a cms i scripted

 

each static page will have its own row in the database

 

the current amount of static pages is unbelievable, this is why i need to for loop and dump one by one

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.