private static long getNumberOfRowsInDatabase(DataSource datasource) throws Exception {
    String rowQuerySql = "SELECT COUNT(*) as total FROM " + TABLE_NAME;
    long numberOfRows = 0;
    try (Connection connection = datasource.getConnection()) {
      try (PreparedStatement queryStatement = connection.prepareStatement(rowQuerySql)) {
        try (ResultSet result = queryStatement.executeQuery()) {
          while (result.next()) {
            numberOfRows = result.getLong("total");
          }
        }
      }
    }
    return numberOfRows;
  }
Get total number of rows of the target table.
@param datasource Datasource to execute query on.
@return Total number of rows
@throws Exception
ambry-tools/src/main/java/com/github/ambry/tools/perf/NamedBlobMysqlDatabasePerf.java