Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id A05189FA5EB for ; Fri, 31 Aug 2007 11:56:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 79473-02 for ; Fri, 31 Aug 2007 11:56:14 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from el-out-1112.google.com (el-out-1112.google.com [209.85.162.183]) by postgresql.org (Postfix) with ESMTP id 00DEF9FA58F for ; Fri, 31 Aug 2007 11:56:22 -0300 (ADT) Received: by el-out-1112.google.com with SMTP id r27so247763ele for ; Fri, 31 Aug 2007 07:56:21 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=qZeRAzUxoJ2ZYaLbQz/QgQSQvmdx2SEWQvqwVu+ksPDykjtOPEl5VC//ozUcgf+y4zrjSzpx/G+1EGc4a8UO9rK+gojIYImsd7tRBfsnZ/xTl3DSZODkc34KEwyMOvZmNsrUjU4hI0pAcBaUK2A15mg8gIKMHDuQyp8UoCb9Tv0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=WWNpnGLcFPSEhA2uEphqel2KKO0yjR2begAO5DpKsmma0u0kR/Yjj/YXMxxeN06RdnSjJ0nZEU4mEdX5GKHE0j/kaevB3eDoZQaC3oVXv+tJObjS2jo8LZ+gCPK1bKYviYywn7q8VlhSuLVo4I38o/5YiN7206Wl++FJCxyCW7c= Received: by 10.100.137.18 with SMTP id k18mr1628703and.1188572180903; Fri, 31 Aug 2007 07:56:20 -0700 (PDT) Received: from ?10.0.0.75? ( [213.170.101.138]) by mx.google.com with ESMTPS id r38sm1345868ugc.2007.08.31.07.56.19 (version=SSLv3 cipher=RC4-MD5); Fri, 31 Aug 2007 07:56:20 -0700 (PDT) Message-ID: <46D82C11.5090506@gmail.com> Date: Fri, 31 Aug 2007 18:56:17 +0400 From: Aleksandr Vinokurov User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Gregory Stark CC: pgsql-sql@postgresql.org Subject: Re: Incomprehensible dogged sort in Merge Join References: <46D82318.3070700@gmail.com> <877inb225q.fsf@oxford.xeocode.com> In-Reply-To: <877inb225q.fsf@oxford.xeocode.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/263 X-Sequence-Number: 29201 Gregory Stark wrote: > "Aleksandr Vinokurov" writes: > >> And that is its plan (attached one is the same, but with costs): >> >>> -----------------------------------------------------------------< >> Merge Left Join >> Merge Cond: ("outer".name = "inner".name) >> -> Sort >> Sort Key: log.name >> -> Seq Scan on log_example_3 log >> -> Sort >> Sort Key: uh.name >> -> Subquery Scan uh >> -> Sort >> Sort Key: name >> -> Seq Scan on user_history >>> -----------------------------------------------------------------< > > What version are you running with? 8.0.1, sorry for missing. > > Incidentally with CVS HEAD I see it working: > > postgres=# explain select * from (select * from a order by i) as a right join b on a.i = b.i ; > QUERY PLAN > ----------------------------------------------------------------- > Merge Right Join (cost=299.56..675.13 rows=22898 width=16) > Merge Cond: (public.a.i = b.i) > -> Sort (cost=149.78..155.13 rows=2140 width=8) > Sort Key: public.a.i > -> Seq Scan on a (cost=0.00..31.40 rows=2140 width=8) > -> Sort (cost=149.78..155.13 rows=2140 width=8) > Sort Key: b.i > -> Seq Scan on b (cost=0.00..31.40 rows=2140 width=8) > (8 rows) > > > >> With best regards to all of you, >> Aleksandr. >> ÿþ > > gesundheit. > > Best wishes, Aleksandr.