PostgreSQL 18 preview - 支持copy 物化视图 to
PostgreSQL 18 preview - 支持copy 物化视图 to
PostgreSQL 18 支持copy 物化视图 to .
例子
+-- Tests for COPY TO with materialized views.
+-- COPY TO should fail for an unpopulated materialized view
+-- but succeed for a populated one.
+CREATE MATERIALIZED VIEW copytest_mv AS SELECT 1 AS id WITH NO DATA; +COPY copytest_mv(id) TO stdout WITH (header);
+ERROR: cannot copy from unpopulated materialized view "copytest_mv"
+HINT: Use the REFRESH MATERIALIZED VIEW command.
+REFRESH MATERIALIZED VIEW copytest_mv;
+COPY copytest_mv(id) TO stdout WITH (header);
+id
+1
+DROP MATERIALIZED VIEW copytest_mv;
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=534874fac0b34535c9a5ab9257d6574f78423578
Allow "COPY table TO"command to copy rows from materialized views.
author Fujii Masao <[email protected]>
Fri, 4 Apr 2025 10:32:00 +0000 (19:32 +0900)
committer Fujii Masao <[email protected]>
Fri, 4 Apr 2025 10:32:00 +0000 (19:32 +0900)
commit 534874fac0b34535c9a5ab9257d6574f78423578
tree c92b33bfbd8fa96270cf5215047fb02030c022a6 tree
parent 9ef1851685b718264de47bf543505cf3ec25aaea commit | diff
Allow "COPY table TO"command to copy rows from materialized views. Previously, "COPY table TO"command worked only with plain tables and
did not support materialized views, even when they were populated and
had physical storage. To copy rows from materialized views,
"COPY (query) TO"command had to be used, instead.
This commit extends "COPY table TO" to support populated materialized
views directly, improving usability and performance, as "COPY table TO"
is generally faster than "COPY (query) TO". Note that copying from
unpopulated materialized views will still result in an error.
Author: jian he <[email protected]>
Reviewed-by: Kirill Reshke <[email protected]>
Reviewed-by: David G. Johnston <[email protected]>
Reviewed-by: Vignesh C <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/CACJufxHVxnyRYy67hiPePNCPwVBMzhTQ6FaL9_Te5On9udG=yg@mail.gmail.com