Skip to content

Commit 48395c9

Browse files
authored
Merge pull request #128 from dathere/syc_buffer_with_copyexpert
sync read buffer with buffer size of copyexpert
2 parents 6e21862 + 842dd99 commit 48395c9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

datapusher/dot-env.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ WRITE_ENGINE_URL = 'postgresql://datapusher:YOURPASSWORD@localhost/datastore_def
1414
SQLALCHEMY_DATABASE_URI = 'postgresql://datapusher_jobs:YOURPASSWORD@localhost/datapusher_jobs'
1515

1616
# READ BUFFER SIZE IN BYTES WHEN READING CSV FILE WHEN USING POSTGRES COPY
17-
# default 1mb = 1048576
18-
COPY_READBUFFER_SIZE = 1048576
17+
# default 64k = 65536
18+
COPY_READBUFFER_SIZE = 65536
1919

2020
# =============== DOWNLOAD SETTINGS ==============
2121
# 25mb, this is ignored if either PREVIEW_ROWS > 0

datapusher/jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):
14451445
# specify a 1MB buffer size for COPY read from disk
14461446
with open(tmp, "rb", copy_readbuffer_size) as f:
14471447
try:
1448-
cur.copy_expert(copy_sql, f)
1448+
cur.copy_expert(copy_sql, f, size=copy_readbuffer_size)
14491449
except psycopg2.Error as e:
14501450
raise util.JobError("Postgres COPY failed: {}".format(e))
14511451
else:

0 commit comments

Comments
 (0)