mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
First attempt at enhancing the "PRAGMA cache_spill" statement to accept a
cache threashold size. FossilOrigin-Name: 549d42be0dac87dc04c3eeccfdc60615c3a6ad3f
This commit is contained in:
38
src/btree.c
38
src/btree.c
@@ -2556,19 +2556,11 @@ int sqlite3BtreeClose(Btree *p){
|
||||
}
|
||||
|
||||
/*
|
||||
** Change the limit on the number of pages allowed in the cache.
|
||||
**
|
||||
** The maximum number of cache pages is set to the absolute
|
||||
** value of mxPage. If mxPage is negative, the pager will
|
||||
** operate asynchronously - it will not stop to do fsync()s
|
||||
** to insure data is written to the disk surface before
|
||||
** continuing. Transactions still work if synchronous is off,
|
||||
** and the database cannot be corrupted if this program
|
||||
** crashes. But if the operating system crashes or there is
|
||||
** an abrupt power failure when synchronous is off, the database
|
||||
** could be left in an inconsistent and unrecoverable state.
|
||||
** Synchronous is on by default so database corruption is not
|
||||
** normally a worry.
|
||||
** Change the "soft" limit on the number of pages in the cache.
|
||||
** Unused and unmodified pages will be recycled when the number of
|
||||
** pages in the cache exceeds this soft limit. But the size of the
|
||||
** cache is allowed to grow larger than this limit if it contains
|
||||
** dirty pages or pages still in active use.
|
||||
*/
|
||||
int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){
|
||||
BtShared *pBt = p->pBt;
|
||||
@@ -2579,6 +2571,26 @@ int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Change the "spill" limit on the number of pages in the cache.
|
||||
** If the number of pages exceeds this limit during a write transaction,
|
||||
** the pager might attempt to "spill" pages to the journal early in
|
||||
** order to free up memory.
|
||||
**
|
||||
** The value returned is the current spill size. If zero is passed
|
||||
** as an argument, no changes are made to the spill size setting, so
|
||||
** using mxPage of 0 is a way to query the current spill size.
|
||||
*/
|
||||
int sqlite3BtreeSetSpillSize(Btree *p, int mxPage){
|
||||
BtShared *pBt = p->pBt;
|
||||
int res;
|
||||
assert( sqlite3_mutex_held(p->db->mutex) );
|
||||
sqlite3BtreeEnter(p);
|
||||
res = sqlite3PagerSetSpillsize(pBt->pPager, mxPage);
|
||||
sqlite3BtreeLeave(p);
|
||||
return res;
|
||||
}
|
||||
|
||||
#if SQLITE_MAX_MMAP_SIZE>0
|
||||
/*
|
||||
** Change the limit on the amount of the database file that may be
|
||||
|
Reference in New Issue
Block a user