我现在按如下代码把数据读入到内存创建好的对象的时候,初步测试了一下,时间非常慢,大概要半分钟的样子,因为后面还要做其他的处理,所以要求把数据从数据库读入到内存这一过程的速度要尽量快一些。在此想请问一下,有没有做过类似的程序的,或者有什么比较好的建议和方法,请各位指点一下。 while(!m_pRecordset->adoEOF)
{
x=m_pRecordset->GetCollect("x");
y=m_pRecordset->GetCollect("y");
z=m_pRecordset->GetCollect("z");
r=m_pRecordset->GetCollect("r");
g=m_pRecordset->GetCollect("g");
b=m_pRecordset->GetCollect("b");
CPointzb point1;
point1.set(x,y,z);
Points1.push_back(point1);
CPointys point2;
point2.set(r,g,b);
Points2.push_back(point2);
}
{
x=m_pRecordset->GetCollect("x");
y=m_pRecordset->GetCollect("y");
z=m_pRecordset->GetCollect("z");
r=m_pRecordset->GetCollect("r");
g=m_pRecordset->GetCollect("g");
b=m_pRecordset->GetCollect("b");
CPointzb point1;
point1.set(x,y,z);
Points1.push_back(point1);
CPointys point2;
point2.set(r,g,b);
Points2.push_back(point2);
}
PS: CPointzb point1;
point1.set(x,y,z);
Points1.push_back(point1);
CPointys point2;
point2.set(r,g,b);
Points2.push_back(point2);
请问这几步在上面整个代码中占用的时间多吗? vector容器的插入操作效率应该还是蛮高的吧?
有没有可能减少读数的次数?比如xyzrbg弄成一列或两列
point1.set(x,y,z);
point2.set(r,g,b);
顺序都是固定的,完全可以改善数据表存数的方式,比如x限定位数和小数点,xyz存在一起,然后在vc中拆分,不知道这样效率如何?