logoalt Hacker News

jeltzyesterday at 10:33 PM3 repliesview on HN

Threads does not offer any major performance advantage, performance of processes vs threads is virtually the same. The reason the PostgreSQL project is moving towards threads is to make development easier.


Replies

malisperyesterday at 10:46 PM

> Threads does not offer any major performance advantage

This is very not true. When it comes to parallel queries, a process model adds a ton of overhead. You can't pass pointers between processes because the address space is different. This adds a ton of overhead in a bunch of different places. For example when doing a parallel hash join, Postgres will have each worker build a local hash table. Then it will take all the tuples out of the local hash table and copy them through shared memory to the leader who will then construct a new hash table. This duplicates a lot of work as you have to hash the tuples multiple times.

A lot of getting to Clickhouse level performance was making better use of parallelism.

show 2 replies
SigmundAtoday at 12:12 PM

MSSQL can handle 32k open connections no need to run a pooler in front of it, can PG do 32k connections and a process for each?

MSSQL shares cached query plans between connections including jitted code, PG cannot do that and the changes needed to make the plans cross process portable would be extensive while sharing between threads is just normal code sharing between threads.

codesnikyesterday at 10:37 PM

unless you're spawning them for new connections.

show 1 reply