Understanding the PostgreSQL log architecture
If you have compiled PostgreSQL from source, you will see that by default, all the logging generated simply goes to standard error (stderr). Sending log output to stderr straightaway has some wonderful advantages. First of all, it scales. Every database connection produces its log independently, and therefore, there is no central bottleneck.
However, if we want to write the logging information created by PostgreSQL to logfiles, the situation will be a bit more complicated. If all open database connections would chase the same logfile to write data, there would be a serious source of contention inside the system. Dozens of database connections might wait for a single logfile. Logically, this kind of bottleneck will have a significant impact on speed—things would simply not scale.
Tip
Keep in mind that PostgreSQL has been made for high concurrency. There is no use having parallelism during execution if all processes have to wait for a single...