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

Behaviour of Incremental Materialized Views and Partioned tables #132

Open
serra92 opened this issue Aug 4, 2021 · 5 comments
Open

Behaviour of Incremental Materialized Views and Partioned tables #132

serra92 opened this issue Aug 4, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@serra92
Copy link

serra92 commented Aug 4, 2021

Hello,

I've been currently trying out the postgresql build of this repo to experiment the usage of incremental materialized views. The current experimentation I'm doing is not updating the incremental materialized view on inserts. The setup is as follows:

  • I have a table called sellout_indicators that is partitioned by a column called field_id
  • I'm creating an incremental materialized view that is based on some of those partitions and joins them together

Whenever I do an insert on the master table, the incremental materialized view is not updating its data. Is this expected behaviour?

If you need any further details about the implementation of the table or the query that supports the view, feel free to ask.

@yugo-n yugo-n added the bug Something isn't working label Aug 6, 2021
@yugo-n
Copy link
Collaborator

yugo-n commented Aug 6, 2021

Thank you for reporting this!

Hmm, indeed, views on partitions do not seem to work well.
Maybe we have to prohibit views on partitioned tables and partitions.
Anyway, I'll investigate this issue more.

Thanks.

@yugo-n
Copy link
Collaborator

yugo-n commented Aug 6, 2021

A similar report is in pqsql-hackers
https://www.postgresql.org/message-id/OS0PR01MB5682576A59A1C765F7AEDE6B82F09%40OS0PR01MB5682.jpnprd01.prod.outlook.com

I think this is the same issue reported here.

@serra92
Copy link
Author

serra92 commented Aug 6, 2021

This is not a deep search through the code but through some more experimentation and looking into the catalog views, i think what is happening is that the triggers only associate with the specific table itself, whether it is with the partition (that is what is happening on my case) or the master table (on the cases shown on the link you posted). If you would like to see more details on my case, I can show you the query underlying the materialized view and the queries I made on pg_triggers view that I made to understand better what was the underlying issue.

@yugo-n
Copy link
Collaborator

yugo-n commented Aug 6, 2021

Yes, you are right. One reason of this issue is the lack of triggers on partitioned tables or partitions that are not specified in the view definition.
However, even if we create triggers recursively on the parents or children, it would still harder to maintain the view. That is because we will have to convert the format of tuple of modified table to the format of the table specified in the view for cases that the parent and some children have different format. I am not sure whether it is possible, although I'll investigate the way.

@serra92
Copy link
Author

serra92 commented Aug 6, 2021

Thank you very much @yugo-n

@yugo-n yugo-n added enhancement New feature or request and removed bug Something isn't working labels Nov 17, 2022
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