List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:May 5 1999 11:29am
Subject:Re: Threaded applications using mysql
View as plain text  
Shane Wegner wrote:
> Hi,
> I wrote an application which uses threads and I am planning to add Mysql
> support.  My question is one relating to design and that is when a
> multithreaded program uses Mysql using the mysqlclient library, is it best
> to have each thread connect to the Mysql server seperately or is it safe
> to use a shared handle.  The MYSQL_RES and MYSQL_ROW would be local to the
> thread of corse but can the handle be global?  If it can, what will happen
> when two threads submit a query?  Will the second wait until the first
> completes or should this construct just be avoided?
> --
> Shane Wegner: shane@stripped

Hi Shane

You have to give each thread its own connection.
Mysql connections can't handle two concurrent queries.
If you want to reduce the amount of open connections, you can create a connection pool.
This obviously only will spare some connections as long as not all threads are querying at
the same time.


Threaded applications using mysqlShane Wegner5 May
  • Re: Threaded applications using mysqlChristian Mack5 May
    • Re: Threaded applications using mysqlMichael Widenius11 May
  • Re: Threaded applications using mysqlSasha Pachev11 May
    • Re: Threaded applications using mysqlMichael Widenius11 May