dondelelcaro has asked for the wisdom of the Perl Monks concerning the following question:

In a couple of projects I've had, dealing with large amounts of data and a couple of non-interlocking sql queries, I've often wished for a non-blocking DBI so I could prepare a query, have the DB server munch on it, and then when I needed to get the results, call the results using the normal methods, or get a function called through callback.

I've heard rumors that DBD::Sybase does this, but I'm primarly using DBD::Mysql, although in some of my projects, that might be reason to switch to a different database.

Mac mentions that he developed a module that forks off processes to handle the asynch processes, but at least to me, that seems kind of kludgy (and frankly, I'm not sure if I want to be building and tearing down child processes all that often.)

If any of you have faced this, and know of good solutions, preferably for DBD::Mysql, but for any database if it might be portable, I would be most pleased. (Don't hesistate to tell me to RTFM either... just tell me which manual.. ;-)

Replies are listed 'Best First'.
Re: Non-Blocking SQL via DBI
by kschwab (Vicar) on Jul 29, 2001 at 08:09 UTC
    Mysql seems to ignore this sort of thing, since it's built on threads already. I suspect they think you should just use a condition variable within your threaded client. Maybe when Perl 6 has stable threads :)

    PostgreSQL, however, specifically talks about blocking during queries. They seem to have several ways of dealing with it, although I'm not clear on how many of them are supported by the DBD::Pg module.

    In any case, if switching to PostgreSQL is an option, have a look at their page on asynchonous query processing. Then try and figure out how much of it is supported from DBD::Pg :)

Re: Non-Blocking SQL via DBI
by mpeppler (Vicar) on Oct 03, 2001 at 03:43 UTC
    DBD::Sybase does not do this.

    However, Sybase::CTlib does understand this (in recent patch versions of sybperl) - it uses the OpenClient ability to do asynchronous calls to the server.

    Michael