Move db_dump filtering logic into main read-only transaction
-BEGIN;
+BEGIN ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE;
{{~#each tables}}
{{~#if this.filter}}
- CREATE TEMPORARY VIEW "dump_db_{{this.name}}" AS (
+ \copy (
SELECT {{this.columns}}
FROM "{{this.name}}"
WHERE {{this.filter}}
- );
-{{~/if}}
-{{~/each}}
-COMMIT;
-
-BEGIN ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE;
-{{~#each tables}}
-{{~#if this.filter}}
- \copy (SELECT * FROM "dump_db_{{this.name}}") TO 'data/{{this.name}}.csv' WITH CSV HEADER
+ ) TO 'data/{{this.name}}.csv' WITH CSV HEADER
{{~else}}
\copy "{{this.name}}" ({{this.columns}}) TO 'data/{{this.name}}.csv' WITH CSV HEADER
{{~/if}}
