0

I'm importing a database that's almost 2.5 GB inside a docker postgres container. I wanted to know the stimated time and the progress so to check the progress I use PV command like this (I'm not sure if it's the best option)

pv mydb.sql | docker exec -i containerName psql -U postgres -d databaseName

I notice that the performance is really low, so my question is if you guys think that the PIPE that I use with PV command could make the performance of the restore worse. Because I normally used to restore the database like this

docker exec -i containerName psql -U postgres -d databaseName < mydb.sql

and it wasn't that slow before (But I couldn't check the progress), so I'm not sure if it's only my perception or it really may degrade the performance.

This is the performance that PV shows (I'm not sure if that "1:11:33:00" means 1 hour 11 minutes and 33 seconds)

enter image description here

3
  • You'll probably be better off running the command from inside the container instead of docker exec.
    – mustaccio
    Jan 11 at 16:58
  • @mustaccio why is that ? do you think it affect performance ? Jan 12 at 2:27
  • Think what happens when you run docker exec and pipe a file to it.
    – mustaccio
    Jan 12 at 2:51
0

create index statement in SQL is only a few bytes long, but it takes a significant amount of resources to actually complete. Same thing for constraints, matviews. It is not possible to view the progress correctly by tracking the read position of the file.

There is no easy way to track overall progress.

use with PV command could make the performance of the restore worse

At the level of measurement error.

2
  • So you don't think that pv is a good metric to measurethe performance and progress, right ? do you know any other way more accurate ? and finally, do you think that the difference between "pv database.sql | .... " and " .... < database.ql" makes any difference ? like the pipe may degrade the performance ? Jan 11 at 15:44
  • Haven't I already written about these questions? There is no easy way to track overall progress. Nor for plain text format, nor custom or directory. You can track what the PG is doing using the pg_stat_activity view. But it won't say how much is left. Using a pipe will not make a measurable difference.
    – Melkij
    Jan 11 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.