I have a pool of MySQL connections for a web-based data service. When it starts to service a request, it takes a connection from the pool to use. The problem is that if ther
I'm not sure what API you are currently using (or what language), but for Java, there is a special trick the JDBC driver can do.
The standard test query is:
select 1
as you've indicated. If you modify it to:
/* ping */ select 1
the JDBC driver will notice this, and send only a single packet to the MySQL server to get a response.
I learned about this at a Sun 'Deep Dive' episode titled MySQL Tips for Java Developers With Mark Matthews.
Even if you aren't using Java, maybe this same trick has been implemented in other mysql drivers? I assume the server would need to be aware of this special packet so it can send a response...