From: Florian G\. P. <fg...@ph...> - 2003-05-06 14:59:51
|
----- Forwarded message from Michael Neumann <mne...@nt...> ----- Envelope-to: fgp@localhost Delivery-date: Tue, 06 May 2003 14:22:43 +0200 From: Michael Neumann <mne...@nt...> To: "Florian G. Pflug" <fg...@ph...> Subject: Re: ruby-postgres blocks all threads On Tue, May 06, 2003 at 01:05:05PM +0200, Florian G. Pflug wrote: > Hi > > I discovered today that ruby-postgres uses the blocking postgres api when > calling PGconn::exec / PGconn::query. This implies, that all other ruby > threads are blocked until a result is available. > > There are, however, the function PGconn::async_exec and PGconn::async_query > which properly use the nonblocking postgresql api, and use rb_thread_select > to put the calling thread to sleep until the database backend responds. > > These functions are not, as the name might imply, truly asynchronous, in the > sense that they return immediatly after sending the query. They seem (at > least when reading the code) to be a drop-in replacement for exec and query, > but with a more cooperative behaviour. And I thought they were truly asynchronous, so I did not used them. But there might be performance issues. Could you write a simple benchmark, comparing the time needed to insert several thousand rows into Postgres with both variants? > I would recommend to use those functions in the postgres dbd module. > > I did not attach a patch, because simply replacing exec with async_exec is > probably easier than applying a patch ;-)) That's indeed easier. > greetings, Florian Pflug Please post this mail for discussion to the ruby-dbi-devel mailing-list, too. Thanks! Regards, Michael ----- End forwarded message ----- |