Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 3B4369FB1F8 for ; Thu, 19 Oct 2006 08:24:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 14693-05 for ; Thu, 19 Oct 2006 11:23:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from web55908.mail.re3.yahoo.com (web55908.mail.re3.yahoo.com [216.252.110.69]) by postgresql.org (Postfix) with SMTP id 1C9239FB1EE for ; Thu, 19 Oct 2006 08:23:59 -0300 (ADT) Received: (qmail 66835 invoked by uid 60001); 19 Oct 2006 11:23:57 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.ca; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=NMcOX1R0+Txhw/n4THEhixfJ3JX0Sc6MyW5GxkaH9zTdFCSzMyDMEG08qOF/Jd2+0sMb2OmQxRoTrATkDRLH78kD2J5hiV3gEqHRss+2baQTPC9GmypzMP5887awea0Y0G2qUgFho7MIuJdIFqu/GrL0pwi+kArD0nVvbaIR+E0= ; Message-ID: <20061019112357.66833.qmail@web55908.mail.re3.yahoo.com> Received: from [70.29.94.36] by web55908.mail.re3.yahoo.com via HTTP; Thu, 19 Oct 2006 07:23:57 EDT Date: Thu, 19 Oct 2006 07:23:57 -0400 (EDT) From: Ioana Danes Subject: Re: Postgresql 8.1.4 - performance issues for select on view using max To: Jeff Davis , Dimitri Fontaine Cc: pgsql-performance@postgresql.org, Ioana Danes In-Reply-To: <1161207230.31645.266.camel@dogma.v10.wvs> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.2 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200610/392 X-Sequence-Number: 21521 Hello, Actually what I expected from the planner for this query (select max(transid) from view) was something like this : select max(transid) from (select max(transid) from archive.transaction union all select max(transid) from public.transaction) and to apply the max function to each query of the union. This is what is happening when you use a where condition, it is using the indexes on each subquery of the view... ex: select transid from view where transid = 12; This way it would be fast enough. Also for order by and limit I was expecting the same thing. Thank you for your time, Ioana Danes > constraint exclusion and inheritance won't help him. > > The problem is that he has two indexes, and he needs > to find the max > between both of them. PostgreSQL isn't smart enough > to recognize that it > can use two indexes, find the max in each one, and > find the max of those > two values. > > Regards, > Jeff Davis > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com