Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query).

newtglobal postgresql_contributors <postgresql_contributors@newtglobalcorp.com>

From: newtglobal postgresql_contributors <postgresql_contributors@newtglobalcorp.com>
To: pgsql-hackers@lists.postgresql.org
Cc: Jian He <hejian.mark@gmail.com>
Date: 2025-03-13T06:50:31Z
Lists: pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world:  not tested
Implements feature:       not tested
Spec compliant:           not tested
Documentation:            not tested

Hi,
Tested the latest patch that allows direct `COPY` operations on Materialized Views, removing the need for `COPY (SELECT ...)`. This enhancement reduces query overhead, improving performance by **4–5%**.  
Example:  
Previous approach: 
COPY (SELECT * FROM staff_summary) TO STDOUT WITH CSV HEADER;
Optimized approach:  
COPY staff_summary TO STDOUT WITH CSV HEADER;
Performance tests were conducted using a Materialized View containing around 80,000 records, confirming that the new approach is faster and more efficient for exporting data.

Regards,
Newt Global PostgreSQL Contributors

Commits

  1. Allow "COPY table TO" command to copy rows from materialized views.