From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | twanger(at)smartvia(dot)de |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: simpler query significantly slower |
Date: | 2001-05-21 14:37:40 |
Message-ID: | 25232.990455860@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
twanger(at)smartvia(dot)de writes:
> select
> distinct
> gruppen_produkte.produktgruppen_id
> from
> r_gruppen_produkte
> where
> r_gruppen_produkte.gruppen_id = gruppen.gruppen_id // this and the next cond are removed in 2nd query
> and
> gruppen.parent_id=1
> and
> r_gruppen_produkte.gruppen_id = r_personen_bereiche.g_id
> and
> r_personen_bereiche.p_id = 1234
This SQL seems rather seriously confused. It looks to me like you will
get back one copy of each distinct produktgruppen_id value appearing in
gruppen_produkte. Since no gruppen_produkte field is constrained by
WHERE, none will be eliminated. All that the rest of the query does is
cause a completely useless Cartesian-product join against some subset
of r_gruppen_produkte * gruppen * r_personen_bereiche.
Possibly you meant to select from r_gruppen_produkte.
BTW, PG 7.1 would have complained about the lack of FROM entries for
gruppen_produkte, gruppen, and r_personen_bereiche, which might have
clued you to your error ...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Leonid | 2001-05-21 14:38:43 | pg_dump failed |
Previous Message | Jaume Teixi | 2001-05-21 14:19:19 | cannot connect using terminal nor pgaccess |