"Matthew N. Dodd" <winter@jurai.net> writes:
> Also, allowing writes of single characters is bad; you incur a context
> switch each write. The client and server should be writing things into
> largish buffers and writing those instead of doing small writes.
> The existence of the following scare me...
> pqPutShort(int integer, FILE *f)
> pqPutLong(int integer, FILE *f)
> [etc]
Look again. Those functions use <stdio.h>, which provides buffering.
They don't need to do it themselves.
It might be good to put a layer underneath these functions to allow
insertion of encryption or something like that, but efficiency is not
a valid argument for doing it.
On the client side, in the recent libpq rewrite I took out usage of
stdio and did my own buffering instead, but that was just so that
I could control when and how the client would block for input.
I don't think it bought any speedup.
regards, tom lane