X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BBD80D1B4BD for ; Mon, 5 Jan 2004 20:24:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49267-09 for ; Mon, 5 Jan 2004 16:23:34 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 876A8D1B495 for ; Mon, 5 Jan 2004 16:23:33 -0400 (AST) Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 0C9C31F94; Mon, 5 Jan 2004 15:23:18 -0500 (EST) To: siracusa@mindspring.com Cc: Postgres Performance Subject: Re: Select max(foo) and select count(*) optimization From: Neil Conway In-Reply-To: (John Siracusa's message of "Mon, 05 Jan 2004 14:03:12 -0500") References: Date: Mon, 05 Jan 2004 15:23:16 -0500 Message-ID: <87k746p2kr.fsf@mailbox.samurai.com> User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/53 X-Sequence-Number: 5228 John Siracusa writes: > 1. The query "select max(foo) from bar" where the column foo has an index. > Aren't indexes ordered? If not, an "ordered index" would be useful in this > situation so that this query, rather than doing a sequential scan of the > whole table, would just "ask the index" for the max value and return nearly > instantly. http://www.postgresql.org/docs/current/static/functions-aggregate.html -Neil