Herkum has asked for the wisdom of the Perl Monks concerning the following question:
I am saving a bunch of objects to database, and right now I am saving each object individually with its own INSERT statement. So 1000 objects, 1000 insert dbi calls.
I was thinking I could get a performance boost if I made it one large SQL statement and do a batch insert like below
INSERT INTO table (description) VALUES (?),(?),(?) etc...
However, before I go down this road I was wondering if I would really get any performance benefits. Statement handles are already prepared, so that is not an issue, but if I insert 1000 objects, that means I am binding about 40,000 variables to this INSERT statement. I am wondering would that really bring any performance improvements or would I be better served by interpolating the values into the SQL?
Any have advice on the subject?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Batch INSERT performance
by ig (Vicar) on May 05, 2009 at 20:28 UTC | |
by Herkum (Parson) on May 05, 2009 at 20:47 UTC | |
Re: Batch INSERT performance
by samtregar (Abbot) on May 05, 2009 at 20:10 UTC | |
by Herkum (Parson) on May 05, 2009 at 20:18 UTC | |
by roboticus (Chancellor) on May 05, 2009 at 21:06 UTC | |
by samtregar (Abbot) on May 07, 2009 at 15:25 UTC | |
Re: Batch INSERT performance
by Jenda (Abbot) on May 05, 2009 at 23:47 UTC |