How can I increase the speed at which data is retrieved from Oracle's database using OCCI?

82 Views Asked by At

I have around 400,000 rows inside my database and my goal is to retrieve and write to file all those rows using OCCI in the while loop I have created. However this while loop is writing to file extremely slowly. Even when I remove the writing to file code it's still really slow.

The while loop writes about 2k rows to file per minute. 400,000 rows would take about 3 hours. Is there a way to speed this process up?

oracle::occi::Connection *conn = env->createConnection(userName, password, connectString);
oracle::occi::Statement *stmt = conn->createStatement("some select statement");
oracle::occi::ResultSet *rs = stmt->executeQuery();

std::ofstream logFile("temp.txt", std::ios::app);

while ( rs->next( ) == oracle::occi::ResultSet ::Status::DATA_AVAILABLE ) 
{
 res = rs->getString( 1 );
 logFile << res << "\n";

}

Eventually my plan is to add the rows to a struct or a class since I'll have more than one column.

0

There are 0 best solutions below