The following function imports around 60k records in 111 seconds. I've heard others say that copy_from and copy_expert are doing 1 million records in less than a minute. Is there something about using copy_expert that is slowing down process vs using copy_from? Anything I can do to optimize this?
cursor = connection.cursor()
cursor.copy_expert('''
COPY employee_employee (name, slug, title, base, overtime, other, gross, benefits, ual, total, year, status, jurisdiction_id, notes)
FROM STDIN WITH (FORMAT csv, HEADER true, FORCE_NOT_NULL (status));
''', open(csv_fname),
)
As for relevant variables the database connection is from Django (from django.db import connection
). The database is on my local Macbook Pro and is PostgreSQL 10.