pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
slowness when subselect uses DISTINCT
4+ messages / 2 participants
[nested] [flat]

* slowness when subselect uses DISTINCT
@ 2007-04-18 18:16 Stuart McGraw <smcg2297@frii.com>
  2007-04-18 22:43 ` Re: slowness when subselect uses DISTINCT Phillip Smith <phillip.smith@weatherbeeta.com.au>
  0 siblings, 1 reply; 4+ messages in thread

From: Stuart McGraw @ 2007-04-18 18:16 UTC (permalink / raw)
  To: pgsql-sql

I have several times now run into what seems
like similar performance problems with some 
of my postgresql queries.

I have a view that runs reasonably quicky.

I use this view in a subselect in another 
query and that query too runs reasonably
quicky.

The view returns some unwanted duplicate 
rows so I modify it using either DISTINCT 
or GROUP BY to eliminate them.
View still runs reasonably quickly.

I use the modified view as a subselect as
above, but now the query runs 2-3 orders
of magnitude more slowly than before.

Before I go through the effort of putting 
together a specific and concise test case, 
has anyone seen this general pattern and 
have an explanation or advice?  (PG-8.2.3)




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: slowness when subselect uses DISTINCT
  2007-04-18 18:16 slowness when subselect uses DISTINCT Stuart McGraw <smcg2297@frii.com>
@ 2007-04-18 22:43 ` Phillip Smith <phillip.smith@weatherbeeta.com.au>
  2007-04-19 14:20   ` Re: slowness when subselect uses DISTINCT Stuart McGraw <smcg2297@frii.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Phillip Smith @ 2007-04-18 22:43 UTC (permalink / raw)
  To: 'Stuart McGraw' <smcg2297@frii.com>; pgsql-sql

May I suggest you post an EXPLAIN ANALYZE to the group for the query you're
having problems with...?


-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
On Behalf Of Stuart McGraw
Sent: Thursday, 19 April 2007 04:17
To: pgsql-sql@postgresql.org
Subject: [SQL] slowness when subselect uses DISTINCT

I have several times now run into what seems
like similar performance problems with some 
of my postgresql queries.

I have a view that runs reasonably quicky.

I use this view in a subselect in another 
query and that query too runs reasonably
quicky.

The view returns some unwanted duplicate 
rows so I modify it using either DISTINCT 
or GROUP BY to eliminate them.
View still runs reasonably quickly.

I use the modified view as a subselect as
above, but now the query runs 2-3 orders
of magnitude more slowly than before.

Before I go through the effort of putting 
together a specific and concise test case, 
has anyone seen this general pattern and 
have an explanation or advice?  (PG-8.2.3)


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate


*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee.  If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: slowness when subselect uses DISTINCT
  2007-04-18 18:16 slowness when subselect uses DISTINCT Stuart McGraw <smcg2297@frii.com>
  2007-04-18 22:43 ` Re: slowness when subselect uses DISTINCT Phillip Smith <phillip.smith@weatherbeeta.com.au>
@ 2007-04-19 14:20   ` Stuart McGraw <smcg2297@frii.com>
  2007-04-19 22:52     ` Re: slowness when subselect uses DISTINCT Phillip Smith <phillip.smith@weatherbeeta.com.au>
  0 siblings, 1 reply; 4+ messages in thread

From: Stuart McGraw @ 2007-04-19 14:20 UTC (permalink / raw)
  To: pgsql-sql


Phillip Smith wrote:
> May I suggest you post an EXPLAIN ANALYZE to the group for the query you're
> having problems with...?

I will do that but it has happened to me enough that it seems to be
a general pattern, not something specific to one of my queries,
so I thought some communal knowledge may exist.  But apparently
not.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: slowness when subselect uses DISTINCT
  2007-04-18 18:16 slowness when subselect uses DISTINCT Stuart McGraw <smcg2297@frii.com>
  2007-04-18 22:43 ` Re: slowness when subselect uses DISTINCT Phillip Smith <phillip.smith@weatherbeeta.com.au>
  2007-04-19 14:20   ` Re: slowness when subselect uses DISTINCT Stuart McGraw <smcg2297@frii.com>
@ 2007-04-19 22:52     ` Phillip Smith <phillip.smith@weatherbeeta.com.au>
  0 siblings, 0 replies; 4+ messages in thread

From: Phillip Smith @ 2007-04-19 22:52 UTC (permalink / raw)
  To: 'Stuart McGraw' <smcg2297@frii.com>; pgsql-sql

Let's start with one, and whatever is causing it in one, is perhaps in
theory, causing the rest :)

Cheers,
~p

-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
On Behalf Of Stuart McGraw
Sent: Friday, 20 April 2007 00:20
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] slowness when subselect uses DISTINCT


Phillip Smith wrote:
> May I suggest you post an EXPLAIN ANALYZE to the group for the query
you're
> having problems with...?

I will do that but it has happened to me enough that it seems to be
a general pattern, not something specific to one of my queries,
so I thought some communal knowledge may exist.  But apparently
not.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match


*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee.  If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2007-04-19 22:52 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-18 18:16 slowness when subselect uses DISTINCT Stuart McGraw <smcg2297@frii.com>
2007-04-18 22:43 ` Phillip Smith <phillip.smith@weatherbeeta.com.au>
2007-04-19 14:20   ` Stuart McGraw <smcg2297@frii.com>
2007-04-19 22:52     ` Phillip Smith <phillip.smith@weatherbeeta.com.au>

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