Re: 'fake' join and performance ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Peter Galbavy" <peter(dot)galbavy(at)knowtion(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: 'fake' join and performance ?
Date: 2002-10-22 17:39:25
Message-ID: 24033.1035308365@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Peter Galbavy" <peter(dot)galbavy(at)knowtion(dot)net> writes:
> photos=# select * from metadata m, images i WHERE m.name = 'Make' and
> m.value = 'Canon' limit 10;

> Er, what's that nested loop. I *know* I have shot myself in the foot
> somehow,

Yeah, you didn't restrict the reference to images at all.

> but my initial reaction was that the optimiser should just make the
> 'fake' (i.e. unreferenced) reference to another table go away...

That would be in violation of the SQL spec. The query is defined to
return each join row from the cross product of the FROM tables that
meets the condition of the WHERE clause. As you wrote the query, each
metadata row that meets the WHERE clause will be returned exactly as
many times as there are rows in the images table. There is no such
thing as an "unreferenced" FROM entry as far as SQL is concerned.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Galbavy 2002-10-22 18:54:47 Re: 'fake' join and performance ?
Previous Message Stephan Szabo 2002-10-22 17:31:35 Re: 'fake' join and performance ?