On Wed, Jun 7, 2023 at 5:37 PM Andres Freund <and...@anarazel.de> wrote: > I think we're starting to hit quite a few limits related to the process model, > particularly on bigger machines. The overhead of cross-process context > switches is inherently higher than switching between threads in the same > process - and my suspicion is that that overhead will continue to > increase. Once you have a significant number of connections we end up spending > a *lot* of time in TLB misses, and that's inherent to the process model, > because you can't share the TLB across processes.
This is a very good point. Our default posture on this mailing list is to try to maximize use of OS facilities rather than reimplementing things - well and good. But if a user writes a query with FOO JOIN BAR ON FOO.X = BAR.X OR FOO.Y = BAR.Y and then complains that the resulting query plan sucks, we don't slink off in embarrassment: we tell the user that there's not really any fast plan for that query and that if they write queries like that they have to live with the consequences. But the same thing applies here. To the extent that context switching between more processes is more expensive than context switching between threads for hardware-related reasons, that's not something that the OS can fix for us. If we choose to do the expensive thing then we pay the overhead. -- Robert Haas EDB: http://www.enterprisedb.com