952
社区成员
发帖
与我相关
我的任务
分享
PGresult *res = NULL;
res = PQexec(m_pPGConn, strSql.c_str());
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
std::string strError = PQerrorMessage(m_pPGConn);
PQclear(res);
res = NULL;
}
INSERT INTO history_location(id,x,y,z,prision_code,time) values('68058FE3-CC2F-4db3-ADDD-32950870E741',64.600000,190.200000,0.000000,'DBC21927-71A0-4506-9571-F9FD2C701FF7',1493102074000)
CAccessPostSql accessSql;
bool bIsConnected = accessSql.ConnectDB("192.168.1.116",5432,"test","postgres","letu2016");
unsigned nStart = GetTimeStamp_t();
//insert into history_location(id, x, y, z, prision_code, time) values(? , ? , ? , ? , ? , ? )")
char szSql[1024];
for (int i = 0; i < 10000; ++i)
{
sprintf_s(szSql, "insert into history_location(id, x, y, z, prision_code, time) values('%s' , %d , %d , %d , '%s' ,%d )",
CreateGuid().c_str(), 101, 22, 0, "DBC21927-71A0-4506-9571-F9FD2C701FF7", nStart * 1000);
accessSql.ExecuseSql(szSql);
}
unsigned nEnd = GetTimeStamp_t();
int nDiff = nEnd - nStart;
accessSql.DisconnDB();
插入一万条数据,大概用了100秒,而他们那边使用Java用jdbc的方式,大概用了26秒,我就想知道我哪里出现了问题,导致慢那么多