pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martijn van Oosterhout <kleptog@svana.org>
To: Yonatan Goraly <ygoraly@sbcglobal.net>
Cc: pgsql-general@postgresql.org
Subject: Re: Slow performance with no apparent reason
Date: Sun, 26 Oct 2003 18:43:54 +1100
Message-ID: <20031026074354.GB15100@svana.org> (raw)
In-Reply-To: <3F9AEA51.2070701@sbcglobal.net>
References: <3F9AEA51.2070701@sbcglobal.net>

Please supply EXPLAIN ANALYZE output.

On Sun, Oct 26, 2003 at 12:25:37AM +0300, Yonatan Goraly wrote:
> I am in the process of  adding PostgreSQL support for an application, in 
> addition to Oracle and MS SQL.
> I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III board.
> 
> I have a query that generally looks like this:
> 
> SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND t2.p='string' 
> AND t2.q=1
> 
> This query is strikingly slow (about 100 sec when both t1 and t2 has 
> about 1,200 records, compare with less than 4 sec with MS SQL and Oracle)
> 
> The strange thing is that if I remove one of the last 2 conditions 
> (doesn't matter which one), I get the same performance like with the 
> other databases.
> Since in this particular case both conditions ( t2.p='string', t2.q=1) 
> are not required, I can't understand why having both turns the query so 
> slow.
> A query on table t2 alone is fast with or without the 2 conditions.
> 
> I tired several alternatives, this one works pretty well:
> 
> SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND
>     EXISTS (
>             SELECT * FROM t2 t2a WHERE t2a.p='string' AND t2a.q=1 AND 
> t2a.y=t2.y )
> 
> Since the first query is simpler than the second, it seems to me like a bug.
> 
> Please advise
> 
> Yonatan

-- 
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> "All that is needed for the forces of evil to triumph is for enough good
> men to do nothing." - Edmond Burke
> "The penalty good people pay for not being interested in politics is to be
> governed by people worse than themselves." - Plato

view thread (6+ messages)  latest in thread

Message-ID: <20031026074354.GB15100@svana.org>
Permalink:  ../20031026074354.GB15100@svana.org/
Also on:    postgresql.org/message-id/20031026074354.GB15100@svana.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: kleptog@svana.org, ygoraly@sbcglobal.net, pgsql-general@postgresql.org
  Subject: Re: Slow performance with no apparent reason
  In-Reply-To: <20031026074354.GB15100@svana.org>
  References: <3F9AEA51.2070701@sbcglobal.net> <20031026074354.GB15100@svana.org>

* 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