From: Masaru Sugawara <rk73@echna.ne.jp>
To: Richard Emberson <emberson@phc.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Matching columns in rows from two tables
Date: Sun, 24 Feb 2002 23:59:33 +0900
Message-ID: <20020224235923.2DA2.RK73@echna.ne.jp> (raw)
In-Reply-To: <3C77BD47.BD3C748F@phc.net>
References: <20020223151139.DE3F.RK73@echna.ne.jp>
<3C77BD47.BD3C748F@phc.net>
On Sat, 23 Feb 2002 08:03:19 -0800
Richard Emberson <emberson@phc.net> wrote:
> Thank you very much for your help. I managed to create a query with only two select
> statements
> and none of the selects are inner-selects:
>
> SELECT group_set_id, count(*) FROM group_sets , membership
> WHERE membership.user_id = <<input parameter>>
> AND membership.group_id = group_sets.group_id
> GROUP BY group_set_id
> INTERSECT
> SELECT group_set_id, count(*) FROM group_sets
> GROUP BY group_set_id;
>
> There may still be a better (better performance) query,
Quite so. I would think it's probably one of the best way. Practically,
I found my query including "where exists/not exists" is awfully slow if there
are about 1000+ rows.
> but, again, this is the
> best I could
> come up with.
>
> Thanks.
>
> Richard
>
> > On Wed, 20 Feb 2002 13:51:12 -0800
> > Richard Emberson <emberson@phc.net> wrote:
> >
> > > I have the following tables:
> > >
> >
> > ...
> >
> > > -- a group set is a set of one or more groups
> > > CREATE TABLE group_sets (
Regards,
Masaru Sugawara
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: rk73@echna.ne.jp, emberson@phc.net
Subject: Re: Matching columns in rows from two tables
In-Reply-To: <20020224235923.2DA2.RK73@echna.ne.jp>
* 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