"Peter J. Holzer" <hjp-pgsql@xxxxxx> writes: > On 2023-03-14 22:47:43 +0100, Laurenz Albe wrote: >> A query that counts the number of rows in a table of half a million >> rows is quite expensive and keeps a CPU core busy for a while >> (provided everything is cached). At some degree of parallelism, your >> CPU is overloaded, which leads to non-linear slowdown. > The interesting thing is that on my laptop even two concurrent accesses > cause a 100% slowdown. I think this is because the task is actually > memory-bound: The cores may do the counting in parallel, but they have > to read the data from the same RAM (since it's too large to fit in the > CPU cache) and they have to take turns accessing it. I wondered if synchronize_seqscans might exacerbate this behavior by encouraging more cores to be touching the same buffers at the same time. I couldn't measure much difference between having it on vs. off in a pgbench test with all the clients counting the same table ... but maybe on other hardware the effect would show up. regards, tom lane