Re: [PERFORM] Throwing unnecessary joins away

2006-01-13 Thread Jim C. Nasby
On Thu, Jan 12, 2006 at 07:51:22PM +0100, Ott? Havasv?lgyi wrote: > Hi, > > If the join is to a primary key or notnull unique column(s), then > inner join is also ok. But of course left join is the simpler case. > An example: Actually, you need both the unique/pk constraint, and RI (a fact I miss

Re: [PERFORM] Throwing unnecessary joins away

2006-01-13 Thread Jim C. Nasby
On Thu, Jan 12, 2006 at 01:35:07PM +0100, Alessandro Baretta wrote: > Ott? Havasv?lgyi wrote: > >Hi all, > > > >Is PostgreSQL able to throw unnecessary joins? > >For example I have two tables, and I join then with their primary keys, > >say type of bigint . In this case if I don't reference to on

Re: [PERFORM] Throwing unnecessary joins away

2006-01-12 Thread Ottó Havasvölgyi
Hi, If the join is to a primary key or notnull unique column(s), then inner join is also ok. But of course left join is the simpler case. An example: create table person (id serial primary key, name varchar not null); create table pet (id serial primary key, name varchar not null, person_id int n

Re: [PERFORM] Throwing unnecessary joins away

2006-01-12 Thread Scott Marlowe
On Thu, 2006-01-12 at 11:00, Ottó Havasvölgyi wrote: > Hi, > > I think it would be sufficient only for views. In other cases the > programmer can optimize himself. But a view can be a join of other > tables, and it is not sure that all of them are always needed. It all > depends on what I select f

Re: [PERFORM] Throwing unnecessary joins away

2006-01-12 Thread Ottó Havasvölgyi
Hi, I think it would be sufficient only for views. In other cases the programmer can optimize himself. But a view can be a join of other tables, and it is not sure that all of them are always needed. It all depends on what I select from the view. This information could even be calculted at view cr

Re: [PERFORM] Throwing unnecessary joins away

2006-01-12 Thread Szűcs Gábor
Dear Tom, Not sure about Otto's exact problem, but he did mention views, and I'd feel more comfortable if you told me that view-based queries are re-planned based on actual conditions etc. Are they? Also, if you find it unlikely (or very rare) then it might be a configurable parameter. If so

Re: [PERFORM] Throwing unnecessary joins away

2006-01-12 Thread Tom Lane
=?ISO-8859-1?Q?Ott=F3_Havasv=F6lgyi?= <[EMAIL PROTECTED]> writes: > As far as I know SQL Server has some similar feature. It does not join > if not necessary, more exactly: if the result would be the same if it > joined the table. I find it really really hard to believe that such cases arise often

Re: [PERFORM] Throwing unnecessary joins away

2006-01-12 Thread Ottó Havasvölgyi
Hi, As far as I know SQL Server has some similar feature. It does not join if not necessary, more exactly: if the result would be the same if it joined the table. Here is another example: http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0902/en/html/dbugen9/0468.htm This would be

Re: [PERFORM] Throwing unnecessary joins away

2006-01-12 Thread Alessandro Baretta
Ottó Havasvölgyi wrote: Hi all, Is PostgreSQL able to throw unnecessary joins? For example I have two tables, and I join then with their primary keys, say type of bigint . In this case if I don't reference to one of the tables anywhere except the join condition, then the join can be eliminate