SQLite DB open time really long Problem
- by sxingfeng
I am using sqlite in c++ windows, And I have a db size about 60M,
When I open the sqlite db, It takes about 13 second.
sqlite3* mpDB;
nRet = sqlite3_open16(szFile, &mpDB);
And if I closed my application and reopen it again. It takse only less then 1 second.
First, I thought It is because of disk cache. So I preload the 60M db file before sqlite open, and read the file using CFile, However, after preloading, the first time is still very slow.
BOOL CQFilePro::PreLoad(const CString& strPath)
{
boost::shared_array<BYTE> temp = boost::shared_array<BYTE>(new BYTE[PRE_LOAD_BUFFER_LENGTH]);
int nReadLength;
try
{
CFile file;
if (file.Open(strPath, CFile::modeRead) == FALSE)
{
return FALSE;
}
do
{
nReadLength = file.Read(temp.get(), PRE_LOAD_BUFFER_LENGTH);
} while (nReadLength == PRE_LOAD_BUFFER_LENGTH);
file.Close();
}
catch(...)
{
}
return TRUE;
}
My question is what is the difference between first open and second open.
How can I accelerate the sqlite open-process.