Greg Sabino Mullane <htamf...@gmail.com> writes: > Good question. Forking is expensive, and there is also a lot of > housekeeping associated with it that is simply not needed here. We want > this to be lightweight, and simple. No need to fork if we are just going to > do a few strncmp() calls and a send().
send() can block. I think calling it in the postmaster is a nonstarter. For comparison, we make an effort to not do any communication with incoming clients until after forking a child to do the communication. The one exception is if we have to report fork failure --- but we don't make any strong guarantees about that report succeeding. (IIRC, we put the port into nonblock mode and try only once.) That's probably not a behavior you want to adopt for non-edge-case usages. Another point is that you'll recall that there's a lot of interest in switching to a threaded model. The argument that "fork is too expensive" may not have a long shelf life. I'm not taking a position on whether $SUBJECT is a good idea in the first place. regards, tom lane