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 C3730D1B44B for ; Tue, 6 Jan 2004 00:41:15 +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 05126-02 for ; Mon, 5 Jan 2004 20:40:28 -0400 (AST) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id E02B0D1B45D for ; Mon, 5 Jan 2004 20:40:25 -0400 (AST) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AdfGW-0005bM-00 for ; Tue, 06 Jan 2004 01:40:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Adf6a-0005X2-00 for ; Tue, 06 Jan 2004 01:29:56 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1Adf6a-0000oh-00 for ; Tue, 06 Jan 2004 01:29:56 +0100 From: Doug McNaught Subject: Re: Select max(foo) and select count(*) optimization Date: Mon, 05 Jan 2004 19:29:56 -0500 Lines: 12 Message-ID: <87oeth537f.fsf@asmodeus.mcnaught.org> References: <1073348666.19994.3.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) Cancel-Lock: sha1:7WUavIegZvZvtd1zN4AttylaUro= X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/58 X-Sequence-Number: 5233 Paul Tuckfield writes: > In the case of select count(*), one optimization is to do a scan of the > primary key, not the table itself, if the table has a primary key. In a > certain commercial, lesser database, this is called an "index fast full > scan". It would be important to scan the index in physical order > (sequential physical IO) and not in key order (random physical IO) That won't work because you still have to hit the actual tuple to determine visibility. -Doug