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 calledmysql_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)