X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C8853D6EDE for ; Sun, 23 Oct 2005 13:58:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61637-06 for ; Sun, 23 Oct 2005 16:58:08 +0000 (GMT) Received: from v00051.home.net.pl (post.pl [212.85.96.51]) by svr1.postgresql.org (Postfix) with SMTP id 80710DA948 for ; Sun, 23 Oct 2005 13:58:08 -0300 (ADT) Received: from localhost (HELO ?10.16.0.65?) (bogomips.post@home@127.0.0.1) by matrix01b.home.net.pl with SMTP; Sun, 23 Oct 2005 16:58:04 -0000 Subject: Re: Need help in setting optimal configuration for a huge From: Tomasz Rybak To: "Craig A. James" Cc: Kishore B , pgsql-performance@postgresql.org In-Reply-To: <435BBAF0.8080500@modgraph-usa.com> References: <42567e060510221415r2516523l4c3f9b42dee91a09@mail.gmail.com> <435BBAF0.8080500@modgraph-usa.com> Content-Type: text/plain; charset=ISO-8859-2 Date: Sun, 23 Oct 2005 19:17:56 +0200 Message-Id: <1130087877.6708.16.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=-0.061 required=5 tests=[AWL=-0.111, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/317 X-Sequence-Number: 15085 Dnia 23-10-2005, nie o godzinie 09:31 -0700, Craig A. James napisał(a): > MIN() and MAX() -- These are surprisingly slow, because they seem to do a full table scan EVEN ON AN INDEXED COLUMN! In 8.1 this is no true, see the changelog. > I don't understand why, but happily there is an effective substitute: > > select mycolumn from mytable order by mycolumn limit 1; -- same as MIN() > > select mycolumn from mytable order by mycolumn desc limit 1; -- same as MAX() In 8.1 these queries are equivalent: select mycolumn from mytable order by mycolumn limit 1; select min(mycolumn) from mytable; -- Tomasz Rybak