System level performace hints |
|
2011 January 28 |
Previous Slide | Table of Contents | Next Slide |
We have examined since now several
optimization related topics: but all this mainly was to be
intended as “smartly writing well designed queries”.
Although defining a properly planned SQL query surely represents the main factor to achieve optimal performances, this isn't enough. A second level of performance optimization (fine tuning) exist, i.e. the one concerning interactions between the DBMS and the underlying Operating System / File System. |
DB pages / page cache Any SQLite DB simply is a single monolithic file: any data and related info is stored within this files.As in many others DBMS, disk space isn't allocated at random, but is properly structured: the atomic allocation unit is defined as a page, so a DB file simply is a well organized collection of pages. All pages within the same DB must have the same identical size (typically 1KB i.e. 1024 bytes):
so SQLite maintains an internal page cache (stored in RAM), supporting fast access to the most often accessed pages. Quite intuitively, adopting a bigger page cache can strongly reduce the overall I/O traffic; and consequently an higher throughput can be achieved. By default SQLite adopts a very conservative approach, so to require a light-weight memory footprint; the initial page cache will simply store 2000 pages (corresponding to a total allocation of only 20MB). But a so small default page cache surely isn't enough to properly support an huge DB, (may be one ranging in the many-GB size); this will easily become a real bottleneck, causing very poor global performances. |
PRAGMA page_size; |
1024 |
PRAGMA page_count; |
31850 |
PRAGMA freelist_count; |
12326 |
PRAGMA page_size = 4096; |
PRAGMA page_size; |
1024 |
VACUUM; |
PRAGMA page_size; |
4096 |
PRAGMA page_count; |
5197 |
PRAGMA freelist_count; |
0 |
PRAGMA cache_size; |
1000 |
PRAGMA cache_size = 1000000; |
PRAGMA cache_size; |
1000000 |
Requesting a very generously (but wisely) dimensioned page cache usually will grant a great performance boost, most notably when you are processing a very large DB. |
You can modify other important settings using the appropriate
PRAGMAs supported by SQLite:
|
Previous Slide | Table of Contents | Next Slide |
Author: Alessandro Furieri a.furieri@lqt.it | |
This work is licensed under the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license. | |
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |