| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Fernando Schapachnik <fernando(at)mecon(dot)gov(dot)ar> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Optimizer problem in 8.1.6 |
| Date: | 2007-06-22 17:39:41 |
| Message-ID: | 24281.1182533981@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Fernando Schapachnik <fernando(at)mecon(dot)gov(dot)ar> writes:
> Now, combined (sorry for the convoluted query, it is build
> automatically by an app).
> EXPLAIN SELECT DISTINCT p.id
> FROM partes_tecnicos p,
> rel_usr_sector_parte_tecnico r, active_users u
> WHERE ((r.id_parte_tecnico=p.id AND r.id_usr=u.id AND
> u.login='xxx' AND r.id_sector=p.id_sector_actual AND
> p.id_cola_por_ambito=1)
> OR p.id_cola_por_ambito=1)
> AND p.id_situacion!=6;
Is this query really what you want to do? Because the OR overrides all
the join conditions, meaning that rows having p.id_cola_por_ambito=1
AND p.id_situacion!=6 must produce Cartesian products against every
row in each of the other tables.
I think your SQL-building app is broken.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joshua D. Drake | 2007-06-22 17:42:36 | Re: SPI using perl |
| Previous Message | Jasbinder Singh Bali | 2007-06-22 17:38:31 | Re: SPI using perl |