Unix Technical Forum

mysql connections vs threads

This is a discussion on mysql connections vs threads within the MySQL forums, part of the Database Server Software category; --> if i want to have multiple threads each with its own session-connection dos each one do its own mysql_real_connection ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:27 AM
mariposas rand mair fheal greykitten tomys des anges
 
Posts: n/a
Default mysql connections vs threads

if i want to have multiple threads each with its own session-connection
dos each one do its own mysql_real_connection for its own connection block?

or does one connection represent a block of separate transactions
for each thread using it?

for example with postgres - each thread requires its own database connection
is mysql the same or not?

arf meow arf - nsa fodder - not just jenine
al qaeda terrorism nuclear bomb iran taliban big brother
if you meet buddha on the usenet killfile him
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:27 AM
Axel Schwenke
 
Posts: n/a
Default Re: mysql connections vs threads

mariposas rand mair fheal greykitten tomys des anges <mair_fheal@yahoo.com> wrote:
> if i want to have multiple threads each with its own session-connection
> dos each one do its own mysql_real_connection for its own connection block?
>
> or does one connection represent a block of separate transactions
> for each thread using it?
>
> for example with postgres - each thread requires its own database connection
> is mysql the same or not?


It's the same. You *can* share a connection between threads, but only
if you complete the communication cycle from sending the query to
receiving the EOL packet in the response before you hand the connection
to another thread. I still don't recommend that. Just one connection
per application thread (that need the database)

Please also read the manual on how to use MySQL from a multithreaded
application!


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 11:27 AM
mariposas rand mair fheal greykitten tomys des anges
 
Posts: n/a
Default Re: mysql connections vs threads

In article <v07ks4-7oe.ln1@xl.homelinux.org>,
Axel Schwenke <axel.schwenke@gmx.de> wrote:

> mariposas rand mair fheal greykitten tomys des anges <mair_fheal@yahoo.com>
> wrote:
> > if i want to have multiple threads each with its own session-connection
> > dos each one do its own mysql_real_connection for its own connection block?
> >
> > or does one connection represent a block of separate transactions
> > for each thread using it?
> >
> > for example with postgres - each thread requires its own database
> > connection
> > is mysql the same or not?

>
> It's the same. You *can* share a connection between threads, but only
> if you complete the communication cycle from sending the query to
> receiving the EOL packet in the response before you hand the connection
> to another thread. I still don't recommend that. Just one connection
> per application thread (that need the database)


thanks

> Please also read the manual on how to use MySQL from a multithreaded
> application!


would help if i could find it in the manual

arf meow arf - nsa fodder - not just jenine
al qaeda terrorism nuclear bomb iran taliban big brother
if you meet buddha on the usenet killfile him
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 11:27 AM
Axel Schwenke
 
Posts: n/a
Default Re: mysql connections vs threads

mariposas rand mair fheal greykitten tomys des anges <mair_fheal@yahoo.com> wrote:
> In article <v07ks4-7oe.ln1@xl.homelinux.org>,
> Axel Schwenke <axel.schwenke@gmx.de> wrote:
>
>> Please also read the manual on how to use MySQL from a multithreaded
>> application!

>
> would help if i could find it in the manual


http://dev.mysql.com/doc/refman/5.0/...d-clients.html


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com