Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Doing the same tests from psql gives: 1. ~2.5 seconds for INSERT/VALUES 2. ~10 seconds for prepared statement executes 3. ~15 seconds for multiple INSERTs Dan. On Thu, May 10, 2012 at 3:42 PM, Tom Lane wrote: > Alban Hertroys writes: > > On 10 May 2012 15:05, Radosław Smogura wrote:

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Tom Lane
Alban Hertroys writes: > On 10 May 2012 15:05, Radosław Smogura wrote: >> May I ask what kind of planning may occur during insert? > Well, for example, if there's a unique constraint on the table then > the database will have to check that the newly inserted values don't > conflict with values

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Alban Hertroys
On 10 May 2012 15:05, Radosław Smogura wrote: > May I ask what kind of planning may occur during insert? Well, for example, if there's a unique constraint on the table then the database will have to check that the newly inserted values don't conflict with values that are already in the table. It

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Merlin Moncure
On Thu, May 10, 2012 at 6:52 AM, Alban Hertroys wrote: > On 10 May 2012 11:30, Daniel McGreal wrote: >> I put the multi-value inserts in as I was >> curious as to why prepared statements would be slower given they only plan >> the query once (as also does the multi-value insert, I assume). > > Th

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Radosław Smogura
On Thu, 10 May 2012 13:52:29 +0200, Alban Hertroys wrote: On 10 May 2012 11:30, Daniel McGreal wrote: I put the multi-value inserts in as I was curious as to why prepared statements would be slower given they only plan the query once (as also does the multi-value insert, I assume). That's a

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Alban Hertroys
On 10 May 2012 11:30, Daniel McGreal wrote: > I put the multi-value inserts in as I was > curious as to why prepared statements would be slower given they only plan > the query once (as also does the multi-value insert, I assume). That's a common misconception. The reason that prepared statement

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Hi, Unfortunately these are experimental conditions. The conditions surrounding the intended application are such that my two options are prepared statements or many inserts. I put the multi-value inserts in as I was curious as to why prepared statements would be slower given they only plan the qu

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Pavel Stehule
Hello 2012/5/10 Daniel McGreal : > Hi again, > > I did a follow up test using 'multi-value' inserts which is three times > faster than multiple inserts thusly: > if you need speed, use a COPY statement - it should be 10x faster than INSERTS Pavel > > TRUNCATE test; > BEGIN; > INSERT INTO test (

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Hi again, I did a follow up test using 'multi-value' inserts which is three times faster than multiple inserts thusly: TRUNCATE test; BEGIN; INSERT INTO test (one, two, three, four, five) VALUES ('2011-01-01', true, 'three', 4, 5.5) ,('2011-01-01', true, 'three', 4, 5.5) -- 99'998 more , ('2011-0

[GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Hi! My reading to date suggests that prepared statements should be faster to execute than issuing the same statement multiple times. However, issuing 100'000 INSERTs turned out to be more than ten times faster than executing the same prepared statement 100'000 times when executed via pgAdmin. The