visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: which form of INSERT is faster?


By: phpsnook India  Date: 27/09/2008 08:14:55  English  Points: 20 Status: Answered
Quality : Excellent
hai

when the no of columns is 10 rows to be more than 2000 ....which type of insert is best??

1)INSERT INTO example (name, age) VALUES('Timmy Mellowman', '23' );


2)INSERT INTO example (name, age) VALUES('Timmy Mellowman','23'),('jimmy','16'),('johnn','19');


which one is faster 1 or 2???....wille they make any difference when the data to be inserted is HUGE?
By: VGR Date: 27/09/2008 08:34:19 English  Type : Assist
theoretically, the second form os the fastest. It's even the form generated by the mysqldump program.

if you really have that many inserts to perform at once (and only once, right?) then I suggest that you use an other mechanism than INSERT statements : LOAD DATA INFILE .
By: BrianMM Date: 25/09/2009 11:23:11 English  Type : Assist
The 2nd methiod is faster as it is a single statemment.

Doing a for loop naturally would execute X number of statements.

I use this method to import several hundred thousand rows.

However I would reccomend 'batching' in into say chuncks of 2000 (depending on no of columns) just to make sure you don't hammer mysql too much.

Apart from that as suggested, import in CSV format.
By: OpConsole Date: 03/04/2011 19:00:29 English  Type : Comment
force close

Do register to be able to answer

EContact
browser fav
page generated in 337.196830 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page