Enlarge the SQLite database cache intelligently.

This commit is contained in:
JoelKatz
2013-03-19 23:04:47 -07:00
parent d5a2c96907
commit 5494bc3158
8 changed files with 39 additions and 10 deletions

View File

@@ -196,11 +196,18 @@ uint64 SqliteDatabase::getBigInt(int colIndex)
return(sqlite3_column_int64(mCurrentStmt, colIndex));
}
int SqliteDatabase::getKBUsed()
int SqliteDatabase::getKBUsedAll()
{
return static_cast<int>(sqlite3_memory_used() / 1024);
}
int SqliteDatabase::getKBUsedDB()
{
int cur = 0, hiw = 0;
sqlite3_db_status(mConnection, SQLITE_DBSTATUS_CACHE_USED, &cur, &hiw, 0);
return cur / 1024;
}
static int SqliteWALHook(void *s, sqlite3* dbCon, const char *dbName, int walSize)
{
(reinterpret_cast<SqliteDatabase*>(s))->doHook(dbName, walSize);

View File

@@ -58,7 +58,8 @@ public:
void runWal();
void doHook(const char *db, int walSize);
int getKBUsed();
int getKBUsedDB();
int getKBUsedAll();
};
class SqliteStatement

View File

@@ -89,7 +89,8 @@ public:
virtual bool setupCheckpointing(JobQueue*) { return false; }
virtual SqliteDatabase* getSqliteDB() { return NULL; }
virtual int getKBUsed() { return -1; }
virtual int getKBUsedAll() { return -1; }
virtual int getKBUsedDB() { return -1; }
};
#endif