PostgreSQL 19 will introduce native JSON format support for the COPY TO command, enabling direct export of query results or table data as NDJSON (one JSON object per line). The new format supports an optional force_array option to wrap all records in a JSON array. It is incompatible with some standard text/CSV options like HEADER, NULL, and DELIMITER. While a workaround using COPY with a SELECT subquery and to_json() existed before, the new native approach is faster and uses less memory.
Sort: