| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | bombadil(at)wanadoo(dot)es |
| Cc: | Lista PostgreSql <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Problem with a view (not lazy ;) |
| Date: | 2002-02-06 16:46:08 |
| Message-ID: | 6837.1013013968@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
bombadil(at)wanadoo(dot)es writes:
> In my tests with views I have found a problem that can't explain.
Are those EXPLAINs really for equivalent queries? I find it very
suspicious that the estimated number of rows retrieved from "ta" is
so different in the two cases. I wonder whether you used the same
range of "fecha" in both cases.
> from tcnico_aviso ta
> join empleado e on ta.empleado = e.cod
> join presupuesto p on ta.aviso = p.aviso
> join aviso a
> -> left join empresa em on a.empresa = em.cod
> on ta.aviso = a.nmero;
Did you really mean to do it that way, and not as
from tcnico_aviso ta
join empleado e on ta.empleado = e.cod
join presupuesto p on ta.aviso = p.aviso
join aviso a on ta.aviso = a.nmero
left join empresa em on a.empresa = em.cod;
The way you wrote it forces the a-to-em left join to be done first,
which means it will generate lots of join rows that probably won't
be of any use. I suspect you want to do the left join last not first.
See
http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/explicit-joins.html
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Justin Clift | 2002-02-06 17:47:21 | Re: ipc-daemon error |
| Previous Message | Justin Clift | 2002-02-06 16:37:24 | Re: 7.1.3 : copy from stdin is very slow! |