Re: Performance problems with prepared statements

From: Richard Huxton <dev(at)archonet(dot)com>
To: theo(at)flame(dot)co(dot)za
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Performance problems with prepared statements
Date: 2007-10-11 09:12:46
Message-ID: 470DE90E.2060605@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Theo Kramer 2007-10-11 10:33:18 Re: Performance problems with prepared statements
Previous Message Dimitri Fontaine 2007-10-11 08:52:05 Re: building a performance test suite