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

Always create unlogged IMMVs #2

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Conversation

Jamal-B
Copy link

@Jamal-B Jamal-B commented Apr 4, 2025

Description

This PR follows a previous PR proposal that was not merged because it was not accepted by Yugo Nagata, the developer and maintainer of pg_ivm. This new version, which will not be proposed in the original repo and is not intended to be used by others than us, therefore consists of systematically creating the IMMVs in unlogged mode to meet our needs while introducing the minimum of code changes compared to the original repo that we forked. We will indeed need to take advantage of all future developments of pg_ivm while minimizing conflicts related to possible too significant code divergences. The choice to force the non-persistence of IMMVs directly at the desired location is also linked to the fact that we will not be able to rely on the polymorphic aspect of postgresql functions. Indeed, and furthermore, a create_immv() function of our own, replacing the official version in the original repo, would sooner or later conflict with future developments, making it impossible to execute the alter extension pg_ivm update command, which would need to be executed to manage updates without having to destroy existing IMMVs.

In other words, the modification proposed here, which is not the most elegant (unlike the previous proposal), is the simplest way to meet our needs and the associated constraints, both present and future.

Tests

  1. IMMV is created as unlogged
my_database=# \df pgivm.create_immv
/*
                          List of functions
 Schema |    Name     | Result data type | Argument data types | Type 
--------+-------------+------------------+---------------------+------
 pgivm  | create_immv | bigint           | text, text          | func
*/

select pgivm.create_immv('test_immv', 'select 1');

select relname, relpersistence
from   pg_class
where  relname = 'test_immv';

/*
  relname  | relpersistence 
-----------+----------------
 test_immv | u
*/
  1. IMMV non-persistence is preserved after refresh_immv() using with_data = true
select pgivm.refresh_immv('test_immv', true);

select relname, relpersistence
from   pg_class
where  relname = 'test_immv';

/*
  relname  | relpersistence 
-----------+----------------
 test_immv | u
*/
  1. IMMV non-persistence is preserved after refresh_immv() using with_data = false
select pgivm.refresh_immv('test_immv', false);

select relname, relpersistence
from   pg_class
where  relname  = 'test_immv';

/*
  relname  | relpersistence 
-----------+----------------
 test_immv | u
*/

@Jamal-B Jamal-B requested review from coox, desbouis and loliee April 4, 2025 10:00
@Jamal-B Jamal-B self-assigned this Apr 4, 2025
Copy link
Member

@coox coox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ça m'a l'air 👍 !

@Jamal-B Jamal-B merged commit c803620 into main Apr 7, 2025
@Jamal-B Jamal-B deleted the always-create-unlogged-immvs branch April 7, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants