views:

199

answers:

3

Hi,

I'm hoping someone here might help me.

The company I work for would prefer that I use MySQL instead of MSSQL. So I downloaded the latest driver (6.1) and am porting the DB layer.

However I can not find the BeginExecuteReader function which takes a callback as parameter.

Is this for a reason? Or does it work differently with MySQL?

As far as I can see it, if the code doesn't raise a Callback, I would need to poll which makes it slow. Using a blocking thread per connection is also something I want to avoid.

Anyone ideas how to tackle this? (apart from altering the driver which is probably beyond my powers)

R

A: 

i don't know about this connector specifically, but every other connector i've seen for mysql just waits for the server to return the data during the execute() or query() call. the closest you'll get is using the "unbuffered" version, which returns immediately from execute() or query(), but blocks when you attempt to request the next row but it hasn't arrived from the mysql server yet.

longneck
I really want to use the asynchronous data model. Server2003 supports this for a lot of thins (like querying a webpage, querying the database (with MSSQL at least), socket operations, etc). This makes the need to use a lot of threads go away resulting in fast efficient code. Unfortunately MySQL seems to have implemented the Async operation half. Or so it looks like
Toad
+1  A: 

Version 6.3.4 of the MySQL Connector implements async methods but it seems that it only invokes a delegate asynchronously so it will be non-blocking to the calling thread but it won't save any threads from the ThreadPool. Here's the bug report about this.

And, like you said, it doesn't have a callback parameter. Here's the bug report about this.

I believe devart's data providers implement async methods properly, but they aren't free.

Anyway, async database calls do NOT imply better overall scalability by themselves. I recommend reading the article "Should my database calls be Asynchronous?" for an in-depth analysis.

Mauricio Scheffer
@mauricio scheffer: it's not about the async connections to the database, but more that my programs are completely async (using the CCR from Microsoft). Any thread which stalls (blocking) will reduce the performance of my server significantly (Because I only use 1 thread per core).
Toad
@Toad: cool, if you have measured it then disregard my last comment. Anyhow I checked devart's data providers and they also seem to be using the "async delegate" trick so they won't save any threads either.
Mauricio Scheffer
A: 

MySQL thread support seems to me to basically be an afterthought.

You cannot, for example, via the C API, cancel an issued query; rather, the query function simply blocks. To make multiple concurrent queries, one thread is required per query!

Try using Postgres. I've not used it (the C API put me off - all those typedefs), but it certainly has proper support for multi-threaded queries (e.g. async calls, etc).

Blank Xavier