X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A0041D1B548 for ; Mon, 27 Oct 2003 15:09:42 +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 62028-09 for ; Mon, 27 Oct 2003 11:09:14 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 9B7D3D1B529 for ; Mon, 27 Oct 2003 11:09:10 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 96DF636C51; Mon, 27 Oct 2003 10:09:09 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 1AE8zV-0004n7-00; Mon, 27 Oct 2003 10:09:09 -0500 To: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> <20031027071703.GF2979@rlx11.zapatec.com> In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 10:09:09 -0500 Message-ID: <87oew2yay2.fsf@stark.dyndns.tv> Lines: 39 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/669 X-Sequence-Number: 4417 Christopher Browne writes: > In the last exciting episode, dror@zapatec.com (Dror Matalon) wrote: > > I was answering an earlier response that suggested that maybe the actual > > counting took time so it would take quite a bit longer when there are > > more rows to count. That was my theory. I guess it's wrong. There is other work involved in processing a record, but i'm surprised it's as long as the work to actually pull the record from kernel and check if it's visible. > Well, if a "where clause" allows the system to use an index to search > for the subset of elements, that would reduce the number of pages that > have to be examined, thereby diminishing the amount of work. it's not. therein lies the mystery. > Why don't you report what EXPLAIN ANALYZE returns as output for the > query with WHERE clause? That would allow us to get more of an idea > of what is going on... He did, right at the start of the thread. For a 1 million record table without he's seeing select 1 from tab select count(*) from tab being comparable with only a slight delay for the count(*) whereas select 1 from tab where c < 1000 select count(*) from tab where c < 1000 are much faster even though they still use a sequential scan. I'm puzzled why the where clause speeds things up as much as it does. -- greg