pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: gearond@cvc.net
Cc: Dann Corbit <DCorbit@connx.com>
Cc: Denis <denis@next2me.com>
Cc: pgsql-performance@postgresql.org
Cc: pgsql-general@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: [PERFORM] Yet Another (Simple) Case of Index not used
Date: Tue, 15 Apr 2003 10:23:30 -0400 (EDT)
Message-ID: <200304151423.h3FENUf06986@candle.pha.pa.us> (raw)
In-Reply-To: <3E93348C.20208@cvc.net>

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;"
> -------------------------------------------------------------
> 
> A nice little optimization, maybe not possible in a MVCC system.

I think the only thing you can do with MVCC is to cache the value and
tranaction id for "SELECT AGG(*) FROM tab" and make the cached value
visible to transaction id's greater than the one that executed the
query, and invalidate the cache every time the table is modified.

In fact, don't clear the cache, just record the transaction id of the
table modification command so we can use standard visibility routines to
make the cache usable as long as possiible.

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.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073




view thread (35+ messages)  latest in thread

Message-ID: <200304151423.h3FENUf06986@candle.pha.pa.us>
Permalink:  ../200304151423.h3FENUf06986@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200304151423.h3FENUf06986@candle.pha.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pgman@candle.pha.pa.us, gearond@cvc.net, DCorbit@connx.com, denis@next2me.com, pgsql-performance@postgresql.org, pgsql-general@postgresql.org
  Subject: Re: [PERFORM] Yet Another (Simple) Case of Index not used
  In-Reply-To: <200304151423.h3FENUf06986@candle.pha.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox