I've got some code connecting to a MySQL database and running a simple query. I have instrumented everything and my timer is showing that the first query returns after 12 milliseconds. The code does this:
make database connection -> run query -> parse results -> return results
Maybe I'm insane but 12 milliseconds feels like an eternity in the world of computing. Is this the standard amount of time it takes to connect to and run a query on a vanilla install of MySQL?
If not, I need to reevaluate the library I am using to make connections to MySQL.
You need to consider what goes into constructing and destroying a MySQL DB Connection
Please read my post How costly is opening and closing of a DB connection? in the DBA StackExchange. It will explain what buffers are created for each session.
If 12ms seems like eternity to do this, go with the suggestion to do persistent connections. Personally, I shy away from persistent connections. Perhaps setting smaller values for session buffers may help a little.