Re: [HACKERS] SQL 'in' vs join.

2000-12-10 Thread Bruce Momjian
> Don Baccus <[EMAIL PROTECTED]> writes: > > The optimizer should do a better job on your first query, sure, but why > > don't you like writing joins? > > The join wouldn't give quite the same answers. If there are multiple > rows in table2 matching a particular table1 row, then a join would giv

Re: [HACKERS] SQL 'in' vs join.

2000-12-10 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: >> Now that the executor understands about multiple join rules (for >> OUTER JOIN support), I've been thinking about inventing a new join rule >> that says "at most one output row per left-hand row" --- this'd be sort >> of the opposite of the LEFT OUTER J

RE: [HACKERS] SQL 'in' vs join.

2000-12-04 Thread Andrew Snow
> Now, given the two components, each with very low costs, it chooses to > do a sequential scan on the table. I don't get it. Read the FAQ? http://www.postgresql.org/docs/faq-english.html#4.23 "4.23) Why are my subqueries using IN so slow?") - Andrew

Re: [HACKERS] SQL 'in' vs join.

2000-11-30 Thread Don Baccus
At 10:52 AM 11/30/00 -0500, Tom Lane wrote: >Don Baccus <[EMAIL PROTECTED]> writes: >> The optimizer should do a better job on your first query, sure, but why >> don't you like writing joins? > >The join wouldn't give quite the same answers. If there are multiple >rows in table2 matching a partic

Re: [HACKERS] SQL 'in' vs join.

2000-11-30 Thread Tom Lane
Don Baccus <[EMAIL PROTECTED]> writes: > The optimizer should do a better job on your first query, sure, but why > don't you like writing joins? The join wouldn't give quite the same answers. If there are multiple rows in table2 matching a particular table1 row, then a join would give multiple c

Re: [HACKERS] SQL 'in' vs join.

2000-11-30 Thread Don Baccus
At 08:37 AM 11/30/00 -0500, mlw wrote: >> mlw wrote: >> > >> > Why is a "select * from table1 where field in (select field from table2 >> > where condition )" >> > >> > is so dramatically bad compared to: >> > >> > "select * from table1, table2 where table1.field = table2.field and >> > condition"

Re: [HACKERS] SQL 'in' vs join.

2000-11-30 Thread Hannu Krosing
mlw wrote: > > Hannu Krosing wrote: > > > > mlw wrote: > > > > > > Why is a "select * from table1 where field in (select field from table2 > > > where condition )" > > > > > > is so dramatically bad compared to: > > > > > > "select * from table1, table2 where table1.field = table2.field and > > >

Re: [HACKERS] SQL 'in' vs join.

2000-11-30 Thread mlw
Hannu Krosing wrote: > > mlw wrote: > > > > Why is a "select * from table1 where field in (select field from table2 > > where condition )" > > > > is so dramatically bad compared to: > > > > "select * from table1, table2 where table1.field = table2.field and > > condition" > > > > I can't underst

Re: [HACKERS] SQL 'in' vs join.

2000-11-30 Thread Hannu Krosing
mlw wrote: > > Why is a "select * from table1 where field in (select field from table2 > where condition )" > > is so dramatically bad compared to: > > "select * from table1, table2 where table1.field = table2.field and > condition" > > I can't understand why the first query isn't optimized be

[HACKERS] SQL 'in' vs join.

2000-11-29 Thread mlw
Why is a "select * from table1 where field in (select field from table2 where condition )" is so dramatically bad compared to: "select * from table1, table2 where table1.field = table2.field and condition" I can't understand why the first query isn't optimized better than the second one. The 'i