AsyncMysqlQueryResult::clientStats

Returns the MySQL client statistics at the moment the successful query ended.

Description

public function clientStats(): AsyncMysqlClientStats

Returns the MySQL client statistics at the moment the successful query ended.

This information can be used to know how the performance of the MySQL client may have affected the query operation.

Return Values

Examples

You can get some statistical information from the MySQL client when you get an AsyncMysqlQueryResult via the clientStats() method.

<?hh

namespace Hack\UserDocumentation\API\Examples\AsyncMysql\QueryResult\CStats;

use \Hack\UserDocumentation\API\Examples\AsyncMysql\ConnectionInfo as CI;

async function connect(\AsyncMysqlConnectionPool $pool):
  Awaitable<\AsyncMysqlConnection> {
  return await $pool->connect(
    CI::$host,
    CI::$port,
    CI::$db,
    CI::$user,
    CI::$passwd
  );
}
async function simple_query(): Awaitable<int> {
  $pool = new \AsyncMysqlConnectionPool(array());
  $conn = await connect($pool);
  $result = await $conn->query('SELECT name FROM test_table WHERE userID = 1');
  var_dump($result->clientStats()->callbackDelayMicrosAvg());
  $conn->close();
  return $result->numRows();
}

function run(): void {
  $r = \HH\Asio\join(simple_query());
  var_dump($r);
}

run();
Output
float(492.02418518066)
int(1)