0

I am using the COPY command of Postgres to bulk insert data once a minute from an in-memory CSV file. I written the COPY code so that it performs the COPY's in parallel on separate db connections.

My server has 32gb of ram and 16cpus.

I'm getting a high rate of insertion but would like it to be as high as possible.

What are some easy wins to optimize this? I do also have some read queries occurring on the server whilst this bulk COPY is happening (at present it takes about 10 seconds to finish each time). All inserts are being handled by this COPY setup I have.

Background: The DB server has a local SSD it's writing to, and the servers writing to the DB server are in the same data centre with private high speed connections. CPU and memory isn't being maxed out on the DB server either, which inclines me to think there is some config I am missing out on.

2
  • @mustaccio I'm not sure there are any easy bottlenecks. The db server has a local SSD it's writing to, and the servers writing to the db server are in the same data center with private high speed connections. CPU and memory isn't being maxed out on the db server either. Which inclines me to think there is some config I am missing out on... Commented Jul 15, 2020 at 23:08
  • This Q&A might help you.
    – mustaccio
    Commented Jul 15, 2020 at 23:25

0

Browse other questions tagged or ask your own question.