Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


how to access mysql from multiple threads concurrently using -'c++,mysql,c,multithreading,connection-pooling'


how to access mysql from multiple threads concurrently  using -'c++,mysql,c,multithreading,connection-pooling'

We're doing a small benchmark of MySQL where we want to see how it performs for our data.

Part of that test is to see how it works when multiple concurrent threads hammers the server with various queries.

The MySQL documentation (5.0) isn't really clear about multi threaded clients. I should point out that I do link against the thread safe library (libmysqlclient_r.so)

I'm using prepared statements and do both read (SELECT) and write (UPDATE, INSERT, DELETE).


Should I open one connection per thread? And if so: how do I even do this.. it seems mysql_real_connect() returns the original DB handle which I got when I called mysql_init())
If not: how do I make sure results and methods such as mysql_affected_rows returns the correct value instead of colliding with other thread's calls (mutex/locks could work, but it feels wrong)

    

asked Sep 7, 2015 by rajesh
0 votes
492 views



Related Hot Questions



Government Jobs Opening


...