Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2D8DB9FB3AF for ; Wed, 18 Oct 2006 19:11:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 76522-02 for ; Wed, 18 Oct 2006 19:10:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id A9C8E9FB3AC for ; Wed, 18 Oct 2006 19:10:52 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id 1CB4B56456; Wed, 18 Oct 2006 17:10:51 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Wed, 18 Oct 2006 17:10:46 -0500 Date: Wed, 18 Oct 2006 17:10:46 -0500 From: "Jim C. Nasby" To: Jeff Davis Cc: Dimitri Fontaine , pgsql-performance@postgresql.org, Ioana Danes Subject: Re: Postgresql 8.1.4 - performance issues for select on Message-ID: <20061018221046.GG85041@nasby.net> References: <20061018210201.56435.qmail@web55907.mail.re3.yahoo.com> <200610182319.41920.dim@dalibo.com> <1161207230.31645.266.camel@dogma.v10.wvs> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1161207230.31645.266.camel@dogma.v10.wvs> X-Operating-System: FreeBSD 6.1-RELEASE-p10 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.13 (2006-08-11) X-Hashcash: 1:20:061018:pgsql@j-davis.com::H9pY2/KCKiKs4vEB:00000000000000000000 00000000000000000000000019kx X-Hashcash: 1:20:061018:dim@dalibo.com::LatgKrnv0EqDKq5n:00033so X-Hashcash: 1:20:061018:pgsql-performance@postgresql.org::GxWp2qhPuEy87cP0:00000 0000000000000000000000004Twa X-Hashcash: 1:20:061018:ioanasoftware@yahoo.ca::v+OntAfPiVjf54Gd:000000000000000 0000000000000000000000009ccR X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200610/381 X-Sequence-Number: 21510 On Wed, Oct 18, 2006 at 02:33:49PM -0700, Jeff Davis wrote: > On Wed, 2006-10-18 at 23:19 +0200, Dimitri Fontaine wrote: > > Le mercredi 18 octobre 2006 23:02, Ioana Danes a ??crit : > > > I tried the partitioning scenario but I've got into > > > the same problem. The max function is not using the > > > indexes on the two partitioned tables... > > > > > > Any other thoughts? > > > > Did you make sure your test included table inheritance? > > I'm not sure the planner benefits from constraint_exclusion without selecting > > the empty parent table (instead of your own union based view). > > > > 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. Sorry, don't have the earlier part of this thread, but what about... SELECT greatest(max(a), max(b)) ... ? -- Jim Nasby jim@nasby.net EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)