pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonah H. Harris <jonah.harris@gmail.com>
To: theo@flame.co.za
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance problems with prepared statements
Date: Wed, 10 Oct 2007 15:55:07 -0400
Message-ID: <36e682920710101255n5760a009v8fdbf42e4599f16f@mail.gmail.com> (raw)
In-Reply-To: <1192027540.2495.3.camel@localhost.localdomain>
References: <1192027540.2495.3.camel@localhost.localdomain>

On 10/10/07, Theo Kramer <theo@flame.co.za> wrote:
> When running the query directly from psql it returns the required rows
> in less than 100 milli-seconds.
>
> However, when using a prepared statement from my C application on the
> above query and executing it the query duration is as follows
> ...
> Row[s] = 25, Duration = 435409.474 ms
>

How are you timing it?  Does it really take 435 seconds to complete?
Try the following in psql:

postgres# PREPARE yourplan (VARCHAR, INT, INT) AS
SELECT oid, * FROM calllog
WHERE calllog_mainteng = $1
AND calllog_phase = $2
AND calllog_self < $3
OR calllog_mainteng = $1
AND calllog_phase < 8
ORDER BY calllog_mainteng DESC,
 calllog_phase DESC,
 calllog_self DESC limit 25;

postgres# EXECUTE yourplan('124         ', 8, 366942);

-- 
Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324
EnterpriseDB Corporation                | fax: 732.331.1301
499 Thornall Street, 2nd Floor          | jonah.harris@enterprisedb.com
Edison, NJ 08837                        | http://www.enterprisedb.com/



view thread (18+ messages)  latest in thread

Message-ID: <36e682920710101255n5760a009v8fdbf42e4599f16f@mail.gmail.com>
Permalink:  ../36e682920710101255n5760a009v8fdbf42e4599f16f@mail.gmail.com/
Also on:    postgresql.org/message-id/36e682920710101255n5760a009v8fdbf42e4599f16f@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jonah.harris@gmail.com, theo@flame.co.za
  Subject: Re: Performance problems with prepared statements
  In-Reply-To: <36e682920710101255n5760a009v8fdbf42e4599f16f@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox