The article is really unclear. COPY from a file is a fully server-side process, the server opens and loads the file directly.
However the code linked to is from psql, the CLI tool. This is for the \copy CLI command (which invokes COPY FROM STDIN on the server).
So while it’s correct that this code is talking to libpq, it really has nothing to do with how COPY is faster than a bulk INSERT. From the psql side there isn’t much difference between them, it just sends data to the server.
However the code linked to is from psql, the CLI tool. This is for the \copy CLI command (which invokes COPY FROM STDIN on the server).
So while it’s correct that this code is talking to libpq, it really has nothing to do with how COPY is faster than a bulk INSERT. From the psql side there isn’t much difference between them, it just sends data to the server.
The actual code for copy is here https://github.com/postgres/postgres/blob/master/src/backend...