"select * from tables"
查詢非常緩慢,得到的結果:MySQL的連接器(的libmysql/C)是變得非常緩慢在MySQL連接器/的libmysqlçRES
這裏是我的代碼在C:
int getfrommysql() {
time_t starttime, endtime;
time(&starttime);
double st;
st = GetTickCount();
MYSQL *sqlconn = NULL;
MYSQL_RES * res = NULL;
MYSQL_ROW row = NULL;
MYSQL_FIELD * field;
/*char ipaddr[16];
memset(ipaddr,0,sizeof(ipaddr));*/
char * sqlquery = "select * from seat_getvalue";
sqlconn = malloc(sizeof(MYSQL));
sqlconn = mysql_init(sqlconn);
mysql_real_connect(sqlconn, "111.111.111.111", "root", "password", "database", 0, NULL, 0);
char query[100];
memset(query, 0, 100);
strcpy(query, "select * from seat_getvalue");
mysql_query(sqlconn, query);
res = mysql_store_result(sqlconn);
int col_num, row_num;
if (res) {
col_num = res->field_count;
row_num = res->row_count;
printf("\nthere is a %d row,%d field table", res->row_count, res->field_count);
}
for (int i = 0; i < row_num; i++) {
row = mysql_fetch_row(res);
for (int j = 0; j < col_num; j++) {
printf("%s\t", row[j]);
}
printf("\n");
}
mysql_close(sqlconn);
time(&endtime);
double et = GetTickCount();
printf("the process cost time(get by GetTickCount):%f",et-st);
printf("\nthere is a %d row,%d field table", res->row_count, res->field_count);
}
那它!它在打印線上花費太多......查詢和刪除時間大約是60ms這是正確的.....也許我問了一個愚蠢的問題..... tttttthanks很多.. –