Re: Win2K Questions

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Charles H(dot) Woloszynski" <chw(at)clearmetrix(dot)com>, Richard Huxton <dev(at)archonet(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Win2K Questions
Date: 2002-11-08 19:51:39
Message-ID: 3DCC15CB.A3FA5759@nsd.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here is a suggestion.

When a count(*) is computed (for all records) store that value and
unvalidate it if there is a later insert or delete on the table. Next
improvement would be to maintain a count per active transaction.

Bruce Momjian wrote:
>
> Charles H. Woloszynski wrote:
> >
> >
> > Richard Huxton wrote:
> >
> > >Depends on usage patterns and how you build your application. There are a
> > >couple of oddities with workarounds: count() and max() aren't very optimised
> > >for example.
> > >
> > You can 'fix' the max() SNAFU with a new query of the form
> > "select field from tbl limit 1 order by field desc" (not precise
> > syntax, but the idea is correct)
> >
> > I call it a SNAFU since it I hate to have to change queries from
> > something obvious to a more obscure format just to work around
> > an optimizer issue.
> >
> > Not sure if there is an equivalent query to make count() work
> > faster
>
> The problem with optimizing COUNT() is that different backends have
> different tuple views, meaning the count from one backend could be
> different than from another backend. I can't see how to optimize that.
> Does oracle do it? Maybe by looking their redo segements. We don't
> have those because redo is stored in the main table.
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
> + If your life is a hard drive, | 13 Roberts Road
> + Christ can be your backup. | Newtown Square, Pennsylvania 19073
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-11-08 20:49:47 Re: identifying duplicate RI triggers
Previous Message Thomas Swan 2002-11-08 19:17:29 Re: Can't connect to PGSQL