Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADODB Record set- How to fetch Record Asynchronously in between without loading all records into heap memory

5 views
Skip to first unread message

Hasmukh Ginoya

unread,
Jul 8, 2021, 5:25:53 AM7/8/21
to
I am using ADODB C++ for Execute Query like Select * from table. This table having the large data around 4GB. So when i Execute Query then it is fetching all the records and increase heap memory and load all the records on the client machine virtaul memory. this is my code

// **Create Record set Object**
ADODB::_RecordsetPtr m_pRecordSetData= NULL;
HRESULT hr = m_pRecordSetData.CreateInstance(__uuidof(ADODB::Recordset));
m_pRecordSetData->CursorType = ADODB::adOpenStatic;
m_pRecordSetData->CursorLocation = ADODB::adUseClient;
m_pRecordSetData->LockType = ADODB::adLockReadOnly;

**// Create Command Object**
ADODB::_CommandPtr pCmdPtr = NULL;
HRESULT hr = pCmdPtr.CreateInstance(__uuidof(ADODB::Command));
if (FAILED(hr))
{
return pCmdPtr;
}
pCmdPtr->PutCommandType(ADODB::adCmdText);
pCmdPtr->PutCommandTimeout(0);
pCmdPtr->ActiveConnection = m_pConnection;
pCmdPtr->CommandText = L"Select * from Table";

**// Execute Query Select * from table**
_variant_t vtConn;
vtConn.vt = VT_ERROR;
vtConn.scode = DISP_E_PARAMNOTFOUND;
HRESULT hr = m_pRecordSetData->Open((_variant_t((IDispatch *)pCmdPtr)), vtConn,
ADODB::adOpenStatic, ADODB::adLockReadOnly, -1);


So When We execute last line Recordset Open this will block until all the record is fetched. So it consume all the heap memory of the system.

Expectation / Requirement : Can we fetch the record batch wise / few rows only? , So we can allocated that heap memory and release it. So this will not consume all client side heap memory. Can we fetch asynchronously we will get the next record in batch wise? So we don't want to fetch all record in one go.
0 new messages