Re: any experience with multithreaded pg apps?
От | Ben |
---|---|
Тема | Re: any experience with multithreaded pg apps? |
Дата | |
Msg-id | Pine.LNX.4.44.0405071142430.12573-100000@localhost.localdomain обсуждение исходный текст |
Ответ на | Re: any experience with multithreaded pg apps? (Bill Moran <wmoran@potentialtech.com>) |
Список | pgsql-general |
Mark Harrison wrote: > I'm looking for feedback from anybody who has used pg in a > multi-threaded program, particularly one in which several > threads each open a database connection. > > It's documented to work in that scenario, but I'm interested > in anybody who can share some real-world with that. We've wrapped the libpq commands inside some code that makes use of a glib thread pool. On startup, we have a bunch of threads make persistant connections to the database. The rest of our app simply has to push querries onto this pool, and the first available thread will make use of its persistant connection to return the results as fast as possible. If all threads are busy working on queries, our wrapper code takes care of the queuing for us. It's a scaleable solution that we can make as complex as we want. (For instance, if the database crashes, each thread should be able to re-establish its connection.) It works pretty well. The only drawback is that the application can't make use of the threadpool for multi-query transactions, but we've wrapped all of those in stored procs anyway.
В списке pgsql-general по дате отправления: