sraoss / pg_ivm

IVM (Incremental View Maintenance) implementation as a PostgreSQL extension
Other
862 stars 24 forks source link

Add refresh_immv() function #14

Closed thoshiai closed 2 years ago

thoshiai commented 2 years ago

This patch add refresh command(without document). refresh_immv(immv_name, with_no_data) has two argument. immv_name is incrementaly matview name, and with_no_data is refresh command option.

its with_no_data and WITH NO DATA option of REFRESH MATERIAEZED VIEW mean the same. However, with_no_data has no data, but can be referenced by SELECT.

e.g.

test=# CREATE TABLE test(id int);
CREATE TABLE
test=# INSERT INTO test SELECT generate_series(1, 5);
INSERT 0 5
test=# SELECT create_immv('immv', 'SELECT * FROM test');
NOTICE:  could not create an index on immv "immv" automatically
DETAIL:  This target list does not have all the primary key columns, or this view does not contain DISTINCT clause.
HINT:  Create an index on the immv for efficient incremental maintenance.
 create_immv 
-------------
           5
(1 row)

test=# SELECT refresh_immv('immv', true);
 refresh_immv 
--------------
            0
(1 row)

test=# SELECT * FROM immv;
 id 
----
(0 rows)