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 17EFED8416 for ; Sun, 23 Oct 2005 14:06:12 -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 67421-04 for ; Sun, 23 Oct 2005 17:06:10 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3864BD6F13 for ; Sun, 23 Oct 2005 14:06:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j9NH67dn020904; Sun, 23 Oct 2005 13:06:07 -0400 (EDT) To: "Craig A. James" Cc: Kishore B , pgsql-performance@postgresql.org Subject: Re: Need help in setting optimal configuration for a huge In-reply-to: <435BBAF0.8080500@modgraph-usa.com> References: <42567e060510221415r2516523l4c3f9b42dee91a09@mail.gmail.com> <435BBAF0.8080500@modgraph-usa.com> Comments: In-reply-to "Craig A. James" message dated "Sun, 23 Oct 2005 09:31:44 -0700" Date: Sun, 23 Oct 2005 13:06:07 -0400 Message-ID: <20903.1130087167@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/318 X-Sequence-Number: 15086 "Craig A. James" writes: > MIN() and MAX() -- These are surprisingly slow, because they seem to do a full table scan EVEN ON AN INDEXED COLUMN! 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() BTW, Postgres does know to do that for itself as of 8.1. regards, tom lane