Bug 331158 r=vladimir Add preload capability to storage service for sqlite pager cache.

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@194148 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brettw%gmail.com
2006-04-11 17:37:13 +00:00
parent 00d8899ded
commit febc149ee0
2 changed files with 32 additions and 1 deletions

View File

@@ -21,6 +21,7 @@
*
* Contributor(s):
* Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
* Brett Wilson <brettw@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -49,7 +50,7 @@ interface nsIFile;
* creating prepared statements, executing SQL, and examining database
* errors.
*/
[scriptable, uuid(4c459c8a-f548-42b7-8d7e-42ea1aed3876)]
[scriptable, uuid(77015f88-bfc2-4669-b1c3-cc19fb07cd4e)]
interface mozIStorageConnection : nsISupports {
/*
* Initialization and status
@@ -192,4 +193,20 @@ interface mozIStorageConnection : nsISupports {
void createFunction(in string aFunctionName,
in long aNumArguments,
in mozIStorageFunction aFunction);
/**
* This is used to preload the database cache. It loads pages from the
* start of the database file until the memory cache (specified by
* "PRAGMA cache_size=") is full or the entire file is read.
*
* The cache MUST be active on the database for this to work. This means
* that you must have a transaction open on the connection, or have a
* transaction open on another connection that shares the same pager cache.
* This cached data will go away when the transaction is closed.
*
* This preload operation can dramatically speed up read operations because
* the data is loaded as one large block. Normally, pages are read in on
* demand, which can cause many disk seeks.
*/
void preload();
};

View File

@@ -21,6 +21,7 @@
*
* Contributor(s):
* Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
* Brett Wilson <brettw@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -441,6 +442,19 @@ mozStorageConnection::CreateFunction(const char *aFunctionName,
return NS_OK;
}
/**
* Mozilla-specific sqlite function to preload the DB into the cache. See the
* IDL and sqlite3.h
*/
nsresult
mozStorageConnection::Preload()
{
int srv = sqlite3Preload(mDBConn);
if (srv != SQLITE_OK)
return NS_ERROR_FAILURE;
return NS_OK;
}
/**
** Other bits
**/