Inserting many rows

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Inserting many rows

Post by shivam0101 »

I am inserting some data into a database table. It contains 4 fields. The insertion is done by using a loop. If the data to be inserted is 100-150 rows, will the server hang?

example//

Code: Select all

foreach($datas as $data_key=>$data_value)
{
    mysql_query("INSERT INTO table SET data_key='$data_key', data_value='$data_value'");
 }
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

I see no reason to expect the server to hang, you're just sending it a bunch of short queries.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Try "LOAD DATA INFILE..." instead.
(#10850)
Post Reply