Re: [PERFORM] [GENERAL] Yet Another (Simple) Case of Index not used - Mailing list pgsql-sql

From Richard Huxton
Subject Re: [PERFORM] [GENERAL] Yet Another (Simple) Case of Index not used
Date
Msg-id 200304151729.45657.dev@archonet.com
Whole thread Raw
In response to Re: [PERFORM] [GENERAL] Yet Another (Simple) Case of Index not used  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-sql
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
DO INSTEAD
SELECT quick_count FROM agg_cache WHERE tbl_name='foo';

The whole thing could be handled by user-space triggers/rules and still
invisible to the end-user.

--
  Richard Huxton


pgsql-sql by date:

Previous
From: rute solipa
Date:
Subject: help need it
Next
From: "Pedro Igor Craveiro e Silva"
Date:
Subject: accent problems