Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A7D2347639D for ; Tue, 22 Oct 2002 13:31:40 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 9693A47610A for ; Tue, 22 Oct 2002 13:31:36 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 62477D609; Tue, 22 Oct 2002 10:31:35 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 57F7E5C02; Tue, 22 Oct 2002 10:31:35 -0700 (PDT) Date: Tue, 22 Oct 2002 10:31:35 -0700 (PDT) From: Stephan Szabo To: Peter Galbavy Cc: Subject: Re: 'fake' join and performance ? In-Reply-To: <054501c279e5$8bfcfe00$4528a8c0@cblan.mblox.com> Message-ID: <20021022102934.U88979-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/282 X-Sequence-Number: 9999 On Tue, 22 Oct 2002, Peter Galbavy wrote: > OK, I am now confused; postgresql 7.3beta2 on OpenBSD: > > > photos=# select * from metadata WHERE name = 'Make' and value = 'Canon' > limit 10; > > *bang*, 10 values, sub second response. > > photos=# select * from metadata m, images i WHERE m.name = 'Make' and > m.value = 'Canon' limit 10; > > *yawn* - see you later... > > ---------------------------------------------------------------------------- > ------------------------ > Limit (cost=0.00..27712.04 rows=6 width=816) > -> Nested Loop (cost=0.00..31073.00 rows=7 width=816) > -> Index Scan using metadata_index_2 on metadata m > (cost=0.00..31072.94 rows=7 width=92) > Index Cond: (name = 'Make'::text) > Filter: (value = 'Canon'::text) > -> Seq Scan on images i (cost=0.00..0.00 rows=1 width=724) > (6 rows) > > > > Er, what's that nested loop. I *know* I have shot myself in the foot > somehow, but my initial reaction was that the optimiser should just make the > 'fake' (i.e. unreferenced) reference to another table go away... It can't do that. The second query would give multiple copies of each row in metadata for each row in images. I'm surprised that it'd be so slow if images is completely empty though. What does explain analyze show for the real times.