Re: Matching columns in rows from two tables

From: Masaru Sugawara <rk73(at)echna(dot)ne(dot)jp>
To: Richard Emberson <emberson(at)phc(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Matching columns in rows from two tables
Date: 2002-02-24 14:59:33
Message-ID: 20020224235923.2DA2.RK73@echna.ne.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sat, 23 Feb 2002 08:03:19 -0800
Richard Emberson <emberson(at)phc(dot)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(at)phc(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Otis Gospodnetic 2002-02-24 20:18:54 PLPGSQL func. defn. for returning resultset?
Previous Message Henry 2002-02-24 07:44:06 callable statement support