On 17 April 2013 17:51, Josh Berkus <josh@agliodbs.com> wrote:
> Regrading MatViews, let me explain why the Refresh locking isn't the
> albatross which some people think it is. Currently, my clients, and
> several OSS projects, have many applications which currently use tables
> as materialized views. The common way to handle these is "BEGIN;
> TRUNCATE matview; INSERT INTO matview SELECT ...; COMMIT;". This
> produces the *exact same* locking pattern as the current REFRESH. While
> more lock-sensitive patterns are possible, that doesn't mean people are,
> in the mainstream, using them.
I agree that the above code has exactly the same locking pattern as a refresh.
Only trouble is that isn't the best way of doing it, nor in my
experience the common way of doing it.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services