Ok after all the performance look's great I think my problem was
mysql_ping() after reading the description again I found that we must
use this only when there was a significant idle period and not every
query like I was doing.
I guess the normal behaviour is to wait after an error and then
reconnect if possible?
From: Julien Chavanton
Sent: September 18, 2006 3:31 PM
Subject: Connection sharing vs lost of query per connections
I have a design concern with MySql++, I have multithreaded software that
can have 1000 threads simultaneously connecting to a Mysql server
At first I made one connection per thread but it quickly becomes a
performance problem, the system was taking to long to connect.
Then I switched to one connection for each server/database shared
amongst the threads.
Now I receive `MySQL server has gone away ` reading the online doc I now
read a contradictory advice to use many connections, anyone as a
scalable solution to share?
* You can also encounter this error with applications that fork
child processes, all of which try to use the same connection to the
MySQL server. This can be avoided by using a separate connection for
each child process.