Please see screenshot below. The values highlighted jump between 80 and 95 percent.
As you can see, the postgres process is taking up all the CPU. However, the user processes percentage is only 5%. As a matter of fact, the majority of the CPU is considered idle. The dashboard on Google Cloud also says that the machine has most CPU idle.
I've collected information here Linux "top" command: What are us, sy, ni, id, wa, hi, si and st (for CPU usage)?
and here: https://scoutapm.com/blog/understanding-linuxs-cpu-stats
The latter source specifically says that databases are part of the 'user space' part. How can this discrepancy be explained? Does it have something to do with different CPU cores?
Update:
Pressing 1
after doing the top
command displays cpu use per core:
There are 18 (!) CPU cores. As you can see, one of them is totally eaten up by postgres but the rest is empty. Am I to understand that the %CPU as listed in the top command only shows how much it takes of a single core? This was not clear to me from the sources I have found.
Taking a more solution oriented approach: Adding more cores won't do anything. Rather expanding the size of the CPU running the postgres process could potentially lower the CPU percentage it uses?
1
in top to list all CPUs separately.