Re: Performance problems with prepared statements - Mailing list pgsql-performance

From Richard Huxton
Subject Re: Performance problems with prepared statements
Date
Msg-id 470DE90E.2060605@archonet.com
Whole thread Raw
In response to Re: Performance problems with prepared statements  (Theo Kramer <theo@flame.co.za>)
Responses Re: Performance problems with prepared statements
List pgsql-performance
Theo Kramer wrote:
> Thanks, had missed that, however, I am afraid that I fail to see how
> preparing a query using PQprepare() and then executing it using
> PQexecPrepared(), is 8 thousand times slower than directly executing
> it.,, ( 403386.583ms/50.0ms =  8067 ).
>
> When doing a 'manual' prepare and explain analyze I get the following

> rascal=# explain analyze execute cq ('124         ', 8, 366942);
>  Total runtime: 3.272 ms
>
> So I suspect that there is something more fundamental here...

OK, so there must be something different between the two scenarios. It
can only be one of:
   1. Query
   2. DB Environment (user, locale, settings)
   3. Network environment (server/client/network activity etc)

Are you sure you have the parameter types correct in your long-running
query?
Try setting log_min_duration_statement=9000 or so to capture
long-running queries.

Make sure the user and any custom settings are the same. Compare SHOW
ALL for both ways.

You've said elsewhere you've ruled out the network environment, so
there's not point worrying about that further.

--
   Richard Huxton
   Archonet Ltd

pgsql-performance by date:

Previous
From: Dimitri Fontaine
Date:
Subject: Re: building a performance test suite
Next
From: Theo Kramer
Date:
Subject: Re: Performance problems with prepared statements