X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 017F5476237; Tue, 15 Apr 2003 12:29:38 -0400 (EDT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by postgresql.org (Postfix) with ESMTP id 0F39F4758F1; Tue, 15 Apr 2003 12:29:37 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 195TJV-0005Iu-0W; Tue, 15 Apr 2003 17:29:41 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 1198B176C4; Tue, 15 Apr 2003 17:29:40 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 6BAFB176BB; Tue, 15 Apr 2003 17:29:39 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Bruce Momjian , gearond@cvc.net Subject: Re: [PERFORM] Yet Another (Simple) Case of Index not used Date: Tue, 15 Apr 2003 17:29:45 +0100 User-Agent: KMail/1.4.3 Cc: Dann Corbit , Denis , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org References: <200304151423.h3FENUf06986@candle.pha.pa.us> In-Reply-To: <200304151423.h3FENUf06986@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304151729.45657.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/893 X-Sequence-Number: 40958 On Tuesday 15 Apr 2003 3:23 pm, Bruce Momjian wrote: > Dennis Gearon wrote: > > from mysql manual: > > ------------------------------------------------------------- > > "COUNT(*) is optimized to return very quickly if the SELECT retrieves > > from one table, no other columns are retrieved, and there is no WHERE > > clause. For example: > > > > mysql> select COUNT(*) from student;" > > ------------------------------------------------------------- > The cleanest way would probably be to create an aggregate cache system > table, and to insert into it when someone does an unqualified aggregate, > and to delete from it when someone modifies the table --- the MVCC tuple > visibility rules are handled automatically. Queries can look in there > to see if a visible cached value already exists. Of course, the big > question is whether this would be a big win, and whether the cost of > upkeep would justify it. If the rule system could handle something like: CREATE RULE quick_foo_count AS ON SELECT count(*) FROM foo=20 DO INSTEAD SELECT quick_count FROM agg_cache WHERE tbl_name=3D'foo'; The whole thing could be handled by user-space triggers/rules and still=20 invisible to the end-user. --=20 Richard Huxton