Re: Postgresql Materialized views

From: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
To: Mark Mielke <mark(at)mark(dot)mielke(dot)cc>
Subject: Re: Postgresql Materialized views
Date: 2008-01-14 17:17:10
Message-ID: 478B9916.2090305@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Mark Mielke wrote:
> Mark Mielke wrote:
>> Counts, because as we all know, PostgreSQL count(*) is slow, and in
>> any case, my count(*) is not on the whole table, but on a subset.
>> Doing this in a general way seems complex to me as it would need to be
>> able to evaluate whether a given INSERT or UPDATE or one of the
>> dependent tables would impact the WHERE clause for the materialized
>> view, and it still wouldn't know which rows to add/update/remove
>> without detailed analysis, so it would either be throwing out the
>> entire materialized view and recreating it on INSERT or UPDATE (or
>> deferring until the next query?) in which case it may be very slow, or
>> it may be very complex.
>
> Bah. I forgot to add: The feature I've been wondering about (and not
> necessarily looking for somebody else to do, although I don't think I
> know the code well enough to do it at this point):
>
> Web applications often make the same queries over and over. While
> memcache can be used to cache results, the memcache interface is
> different from the web application interfere requiring complex code, and
> as well, one loses the transaction guarantees as the memcache results
> are not guaranteed to be up-to-date with the database.

Regarding up-to-dateness note that there is a pgfoundry project that
helps there. http://pgfoundry.org/projects/pgmemcache/ The other
advantages of doing the caching outside the database is that (a) the
memory for the cached results don't have to sit in the database machine,
and (b) you can cache post-processed (rendered into HTML or gifs)
fragments rather than raw data.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannes Dorbath 2008-01-14 17:59:45 Re: Index trouble with 8.3b4
Previous Message Josh Berkus 2008-01-14 16:54:02 Re: Pl/Java broken since Postgresql 8.3-rc1