From: Tomasz Myrta <jasiek@klaster.net>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: sub-select with aggregate
Date: Wed, 23 Oct 2002 16:02:58 +0200
Message-ID: <3DB6AC12.3030506@klaster.net> (raw)
References: <20021023055926.O3876-100000@megazone23.bigpanda.com>
Uz.ytkownik Stephan Szabo napisa?:
> Does using X.group_id=3 in the where clause work better?
It works better, but not if you want to create a view and make
"select * from some_view where group_id=3" :-(
>
> On 7.3 with no statistics for the table, that appears
> to move the filter into the subquery plan rather than the
> outer users scan.
Do you mean the second query will work on 7.3?
select
group_id,
user_id,
a/sum_a as percent_a,
b/sum_b as percent_b
from
users U,
(select
sum(a) as sum_a,
sum(b) as sum_b
from users where group_id=U.group_id) X
where group_id=3;
Tomasz Myrta
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-sql@postgresql.org
Cc: jasiek@klaster.net, sszabo@megazone23.bigpanda.com
Subject: Re: sub-select with aggregate
In-Reply-To: <3DB6AC12.3030506@klaster.net>
* 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