Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A feature to switch between normal materialized view and IMMV #79

Open
yugo-n opened this issue Feb 13, 2020 · 3 comments
Open

A feature to switch between normal materialized view and IMMV #79

yugo-n opened this issue Feb 13, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@yugo-n
Copy link
Collaborator

yugo-n commented Feb 13, 2020

This feature can keep frozen data available in the materialized view during heavy operations on source tables.

Syntax ideas:

ALTER MATERIALIZED VIEW [ IF EXISTS ] name
    SET { NOINCREMENTAL }
or
    SET { NOINCREMENTAL | INCREMENTAL | INCREMENTAL CONCURRENTLY  }
 ALTER MATERIALIZED VIEW ... SET {WITH | WITHOUT} INCREMENTAL REFRESH

or others. Maybe it is better to use REFRESH. We will need more discussions.

Suggested by PAscal
https://www.postgresql.org/message-id/1581458652080-0.post%40n3.nabble.com

@yugo-n
Copy link
Collaborator Author

yugo-n commented Feb 13, 2020

Implementation idea notes:

When switching IMMV -> MV, we just have to drop or disable IVM triggers on base tables. Also pg_class.relisivm flag have to be cleared.

When MV->IMMV, we will have to refresh the view data to the up-to-date state. Therefore, maybe we should use REFRESH command instead of ALTER. Or, we can use ALTER to switch its mode and set the view non-scannable, and then use REFRESH manually to populate the view.

@legrandlegrand
Copy link

legrandlegrand commented Feb 13, 2020

When Switching IMMV -> MV, there should be a way for administrator to check if relation is IMMV or MV. Not sure that \d+ permits this (it does not, after REFRESH WITH NODATA)

When MV->IMMV, hidden columns __x__ could also be missing, and would have to be recreated.

@yugo-n yugo-n added the enhancement New feature or request label Dec 8, 2020
@yugo-n
Copy link
Collaborator Author

yugo-n commented Aug 6, 2021

There is the same request in pgsql-hackers.

https://www.postgresql.org/message-id/OS0PR01MB5682A90859F1B7772460A74082F29%40OS0PR01MB5682.jpnprd01.prod.outlook.com

I'll consider it again...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants