Re: Improving count(*)

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Zeugswetter Andreas DCP SD <ZeugswetterA(at)spardat(dot)at>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Rod Taylor <pg(at)rbt(dot)ca>, Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improving count(*)
Date: 2005-11-18 11:48:53
Message-ID: 437DBFA5.4050208@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Zeugswetter Andreas DCP SD schrieb:
>>>Since that costs, I guess I would make it optional and combine it
>
> with
>
>>>materialized views that are automatically used at runtime, and can
>
> at
>
>>>the same time answer other aggregates or aggregates for groups.
>>>create materialized view xx_agg enable query rewrite as select
>>>count(*), sum (col1) from xx [group by col2];
>>>
>>
>>I wonder how many times you really need a count(*) w/o where clause.
>>If I understand you correctly you are trying to optimize just this one
>
> case?
>
> I guess you have not read to the end. A materialized view with a group
> by
> as indicated in the example is able to answer all sorts of queries
> with or without where clauses ( e.g. ... where col2 = 'x').

But wouldn't that mean I need a materialized view (does we have
that now or do I need to play the usual games with triggers?)
for every possible where condition?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2005-11-18 12:07:47 Re: Numeric 508 datatype
Previous Message Alvaro Herrera 2005-11-18 11:32:07 Re: Numeric 508 datatype