Databases :: MySql :: which form of INSERT is faster? |
|||
| By: phpsnook |
Date: 27/09/2008 08:14:55 |
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 | 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 | 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 | Type : Comment |
|
| force close | |||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








