On Wed, 1 Dec 2021 09:14:31 -0300 Marcos Pegoraro <mar...@f10.com.br> wrote:
> > > > I think the reason why we can't update a materialized view directly is > > because > > it is basically a "view" and it should not contains any data irrelevant to > > its > > definition and underlying tables. If we would have a feature to update a > > materialized view direcly, maybe, it should behave as updatable-view as > > well > > as normal (virtual) views, although I am not sure.... > > > > Well, I didn“t find any place where is detailed why those tables are not > updatable. > And would be fine to be updated through triggers or cron jobs until IVM is > available. > CheckValidRowMarkRel just gives an exception "cannot lock rows in > materialized view ...", but why ? > What are the differences between Materialized Views and tables ? It would be that materialized views are related to its definition query and expected to have contents that is consistent with it, at least at some point in time, I think. In order to allow triggers to update materialized views, we'd need to make OpenMatViewIncrementalMaintenance and CloseMatViewIncrementalMaintenance public since there are static functions in matview.c. However, there is a concern that it will make the contents of a materialized view completely unreliable [1]. Therefore, if we do it, we would need privilege management in some way. [1] https://www.postgresql.org/message-id/flat/CACjxUsP8J6bA4RKxbmwujTVMwMZrgR3AZ7yP5F2XkB-f9w7K7Q%40mail.gmail.com#efbee336d7651ce39bc5ff9574f92002 Regards, Yugo Nagata -- Yugo NAGATA <nag...@sraoss.co.jp>