This article states multiple times that spinning up a process is expensive/very expensive. Is that really true? I ask out of ignorance.
“Compared to other ways of doing parallelism, processes are very expensive, both in terms of taking CPU resources but also the amount of time it takes to spin up a new process.”
“Because it’s expensive to spin up new processes, Postgres will only do this for long-running queries.”
Also:
“There’s been years of people talking about switching Postgres from a process model to a threading model, but nothing concrete has come out of that.”
I’ve read several times that on Linux, the cost between a process and a thread is relatively small.
It’s also important to distinguish between an os thread and a userspace thread. The author said “thread” without qualification, so I don’t know which he meant. Userspace threads can be many times lighter than processes.
A process is significantly more expensive than a thread on a Linux system. The main cost is memory. Processes own their memory which forces the system to duplicate resources, as opposed to threads that are able to share resources.
Where have you red that "the cost between a process and a thread is relatively small."? I would be curious to see a link because the most cursory internet search would show you that it is not true.
It’s all relative. It’s cheap if you think about spinning up new processes to run one off commands. It gets very expensive when you have to spawn it hundreds of times per second, and it can waste cpu cycles that could be used for query processing instead.