I have code similar to the following in a php document that communicates with a mysql database:
$db = new PDO('mysql:host=127.0.0.1;dbname=db;charset=UTF-8', 'name', 'pw',array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY=>true));
$stmt=$db->prepare("SELECT SUM(anything)
FROM table
WHERE date IN (SELECT date FROM table WHERE something=:something AND somethingElse=:somethingElse)
AND somethingElse=:somethingElse1");
This code takes a long time to run in a browser the first time through... if executed again via a refresh it runs over 100 times faster. I'm trying to figure out what causes a pdo statement like this to run so much faster on a refresh and can't figure it out.