postgresql-client icon indicating copy to clipboard operation
postgresql-client copied to clipboard

Bulk uploading: COPY ... FROM STDIN WITH CSV

Open btakita opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. Bulk updates are significantly faster using COPY instead of single sql queries.

Describe the solution you'd like

const { stream } = pg.query(` COPY my_table (col1, col2, etc) FROM STDIN WITH CSV`, { stream: true })
createReadStream('./data.csv').on('data', $=>stream.write($)).on('close', ()=>stream.close())

Describe alternatives you've considered

  • Using psql from shell or another library/language
  • Not using COPY. Use order of magnitude slower queries instead.

Additional context https://www.citusdata.com/blog/2017/11/08/faster-bulk-loading-in-postgresql-with-copy/

btakita avatar Jul 17 '22 19:07 btakita

Hi Brian, thank you for your feedback. COPY operation is not implemented yet. I am marking this issue as a feature request.

erayhanoglu avatar Jul 18 '22 06:07 erayhanoglu