我正在使用 OCCI 和 C++ 从 Oracle 获取数据。该代码运行良好,但我注意到性能有所下降。发生这种情况是因为在 rset->next() 迭代中,一些计算需要时间。这个延迟的影响是oracle连接池有一个连接忙。如果并发请求需要相同的计算,则池中的可能所有连接都将是 BUSY。
Statement *stmt = conn->createStatement (sqlQuery);
ResultSet *rset = stmt->executeQuery ();
while (rset->next ())
{
//Slow computation takes time
compute()
}
stmt->closeResultSet (rset);
conn->terminateStatement (stmt);
env->terminateConnection (conn);
所以我的问题是:我可以复制 Occi::ResultSet (使用共享指针吗?)以便在复制后关闭连接并在释放连接后进行计算?
go_to_oracle( ResultSet &result) {
Statement *stmt = conn->createStatement (sqlQuery);
ResultSet *rset = stmt->executeQuery ();
copy_rset_to_result;
stmt->closeResultSet (rset);
conn->terminateStatement (stmt);
env->terminateConnection (conn);
}
my_method() {
ResultSet *result = NULL
go_to_oracle(result);
//here connection is closed, but we have the data
compute(result) // do this without have connection occupied
}
GitHub上有任何可用的示例吗?