X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 853F2D1B510 for ; Mon, 15 Sep 2003 23:39:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64092-10 for ; Mon, 15 Sep 2003 20:39:08 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 88581D1B532 for ; Mon, 15 Sep 2003 20:39:05 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h8FNd5sl048358 for ; Mon, 15 Sep 2003 23:39:05 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h8FN9xqq044408 for pgsql-performance@postgresql.org; Mon, 15 Sep 2003 23:09:59 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Inconsistent performance Date: Mon, 15 Sep 2003 18:18:50 -0400 Organization: Hub.Org Networking Services Lines: 32 Message-ID: <60d6e1lmph.fsf@dev6.int.libertyrms.info> References: <5.1.0.14.2.20030915172334.00b1fe48@mail.vetstar.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Rational FORTRAN, linux) Cancel-Lock: sha1:dqFxijw7WzYpZSBX4n94KN+o/Hg= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/226 X-Sequence-Number: 3592 jbove@vetstar.com (Joseph Bove) writes: > I do a rather simple query: select count (*) from large-table where > column = some value; > > About 80% of the time, the response time is sub-second. However, at > 10% of the time, the response time is 5 - 10 seconds. Does it seem data-dependent? That is, does the time vary for different values of "some value?" If a particular value is particularly common, the system might well revert to a sequential scan, making the assumption that it is quicker to look at every page in the table rather than to walk through Enormous Numbers of records. I had a case very similar to this where a table had _incredible_ skewing of this sort where there were a small number of column values that occurred hundreds of thousands of times, and other column values only occurred a handful of times. I was able to get Excellent Performance back by setting up two partial indices: - One for WHERE THIS_COLUMN > VITAL_VALUE; - One for WHERE THIS_COLUMN < VITAL_VALUE; The REALLY COMMON values were in the range < VITAL_VALUE. -- output = ("cbbrowne" "@" "libertyrms.info") Christopher Browne (416) 646 3304 x124 (land)