mysql有这么慢吗?(附:story_feature 表里有两百万条数据)下面是部分C++代码:
其中mFeature与feature_map都是stl map 类型。 oss.str("");
oss << " SELECT DISTINCT `story_id` FROM `story_feature` ";
strSQL = oss.str();
res = mDB->execSQL(strSQL.c_str(), strSQL.size());
if (res) {
if (mysql_num_rows(res) <= 0) {
mysql_free_result(res);
return;
} else {
while(row = mysql_fetch_row(res)) {
strSQL1 = " SELECT `term`, `weight` FROM `story_feature` where `story_id` = " + string(row[0]);
feature_map.clear();
res1 = mDB->execSQL(strSQL1.c_str(), strSQL1.size());
}
if (res1) {
if (mysql_num_rows(res1) <= 0) {
mysql_free_result(res1);
return;
} else {
while(row1 = mysql_fetch_row(res1)) {
feature_map[row1[0]] = atof(row1[1]);
}
mysql_free_result(res1);
}
}
mFeature[atoi(row[0])] = feature_map;
}
mysql_free_result(res);
}
} else {
cout << "no data in TDT.story_feature !" << endl;
return;
}
其中mFeature与feature_map都是stl map 类型。 oss.str("");
oss << " SELECT DISTINCT `story_id` FROM `story_feature` ";
strSQL = oss.str();
res = mDB->execSQL(strSQL.c_str(), strSQL.size());
if (res) {
if (mysql_num_rows(res) <= 0) {
mysql_free_result(res);
return;
} else {
while(row = mysql_fetch_row(res)) {
strSQL1 = " SELECT `term`, `weight` FROM `story_feature` where `story_id` = " + string(row[0]);
feature_map.clear();
res1 = mDB->execSQL(strSQL1.c_str(), strSQL1.size());
}
if (res1) {
if (mysql_num_rows(res1) <= 0) {
mysql_free_result(res1);
return;
} else {
while(row1 = mysql_fetch_row(res1)) {
feature_map[row1[0]] = atof(row1[1]);
}
mysql_free_result(res1);
}
}
mFeature[atoi(row[0])] = feature_map;
}
mysql_free_result(res);
}
} else {
cout << "no data in TDT.story_feature !" << endl;
return;
}
http://topic.csdn.net/u/20110315/13/a35b49cb-1550-4c30-b9a5-9e58a6941158.html