Re: sub-select with aggregate

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sub-select with aggregate
Date: 2002-10-23 14:53:43
Message-ID: 3DB6B7F7.2030609@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Uz.ytkownik Stephan Szabo napisa?:
> But you can't do that anyway, because you don't expose group_id
> in the original query. I assume user_id was a mistake then and was
> meant to be group_id or that both were meant to be in the
> select list.
Yes, I meant group_id, but in orginal query I didn't have to add
group_id to select list.

> In the first case changing the order means that the output
> group_id column is X.group_id rather than users.group_id
> (using removes one of them which is why group_id isn't
> ambiguous. In the second it uses on to get both group_ids
> and exposes the one from X.
The problem isn't ambigous columns, but speed.
I think Postgres first performs sub-query with all records from table
(it takes very long time). After this Postgres permforms joining table
with sub-query. The question is: How to speed up query like this? How to
give param group_id from first table (users) to subquery?
Tomasz Myrta

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2002-10-23 15:12:27 Re: sub-select with aggregate
Previous Message Tomasz Myrta 2002-10-23 14:37:16 Re: problem with a query