Make sure that materialized views that contains only (#4499)

Make sure that materialized views that contains only  intermediate results work fine.
pull/4361/head
Önder Kalacı 2021-01-13 13:17:43 +03:00 committed by GitHub
parent 436c9d9d79
commit 7e0826a06b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -351,6 +351,37 @@ SELECT count(*) FROM (SELECT *, random() FROM small_view) as subquery JOIN small
4
(1 row)
CREATE MATERIALIZED VIEW only_intermedate_result AS
WITH cte_1 AS (SELECT * FROM small OFFSET 0) SELECT * FROM cte_1 ORDER BY 1,2;
SELECT * FROM only_intermedate_result ORDER BY 1,2;
id | tenant_id
---------------------------------------------------------------------
1 | 2
6 | 3
7 | 4
8 | 2
14 | 14
250 | 25
470 | 13
(7 rows)
INSERT INTO small VALUES (1000000,1000000);
REFRESH MATERIALIZED VIEW only_intermedate_result;
SELECT * FROM only_intermedate_result ORDER BY 1,2;
id | tenant_id
---------------------------------------------------------------------
1 | 2
6 | 3
7 | 4
8 | 2
14 | 14
250 | 25
470 | 13
1000000 | 1000000
(8 rows)
DROP TABLE large_partitioned;
DROP TABLE small CASCADE;
NOTICE: drop cascades to materialized view small_view
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to materialized view small_view
drop cascades to materialized view only_intermedate_result

View File

@ -255,5 +255,12 @@ DELETE FROM large_partitioned WHERE id in (SELECT * FROM all_small_view_ids);
WITH cte AS (SELECT *, random() FROM small_view) SELECT count(*) FROM cte JOIN small USING(id);
SELECT count(*) FROM (SELECT *, random() FROM small_view) as subquery JOIN small USING(id);
CREATE MATERIALIZED VIEW only_intermedate_result AS
WITH cte_1 AS (SELECT * FROM small OFFSET 0) SELECT * FROM cte_1 ORDER BY 1,2;
SELECT * FROM only_intermedate_result ORDER BY 1,2;
INSERT INTO small VALUES (1000000,1000000);
REFRESH MATERIALIZED VIEW only_intermedate_result;
SELECT * FROM only_intermedate_result ORDER BY 1,2;
DROP TABLE large_partitioned;
DROP TABLE small CASCADE;