
SQLite uses fsync's to guarantee transaction durability and enable recovery from crashes.
#Firefox how to reduce page size free#
VACUUM empties the free pages space of the database file, that means after a vacuum, until there's new free space, inserts will be a little bit more expensive cause they will have to grow the file. Note that this "vacuuming" only deals with internal fragmentation, not the external fragmentation. Performance can significantly degenerate over time scheduling periodic rebuilds of the DB is necessary. This is likely due to a reduction in syscalls and OS readahead. When the Mozilla default page size was changed to 32KB in bug 416330, there was a 4x reduction in SQLite IO waits according to Telemetry. SQLite CHUNK_SIZE feature is a way to minimize this problemįactory-default SQLite page size is 1024 bytes. This is especially problematic on OSX, Linux XFS.
This behavior causes new data blocks to be allocated too.
By default sqlite will grow/shrink the database file by |page_size|. Appending data to an SQLite in multiple sessions often means the OS has to start a new data block that's not adjacent to the previous one. SQLite does not preallocate files by default. Physical/external fragmentation can also happen due to SQLite using inappropriate defaults. Deleting data does not shrink the database, just marks pages as unused. Appending data to multiple tables interleaves tables too. This means both table and index scans are non-sequential until a VACUUM is performed. Eg appending data to columns with indexes causes interleaved index and table data. Your database file can suffer from logical/internal fragmentation due to common SQL patterns. Using the default microsecond precision for timestamps causes unnecessary bloat. Creating indexes on lengthy text fields (like URIs) will cause very large indexes to be stored on disk Every index contains a complete copy of the indexed data. Large transactions cause large journals, so transactions should be kept as small as possible. bug 609122, bug 608422, their size must be limited at a performance cost WAL journals have been known to grow very large, e.g. This is particularly undesirable on mobile devices visited URIs), but have no expiration policy for the data, can easily cause the DB to balloon into tens or hundreds of MBs. Features that regularly add data to the DB (e.g. The list below outlines some of the ways SQLite can backfire on developers. SQLite DBs are simply too complex to be used for relatively simple data storage needs. This isn't an indictment of SQLite itself - any other relational embedded DB would pose the same challenges. As a result, we have repeatedly seen SQLite become a source of performance problems. It's very tempting to take the abstractions it offers at face value and to ignore the complexity happening under the hood. However, when choosing storage formats, we have to keep in mind that SQLite is a powerful and reliable database and that it comes with a lot of hidden complexity. It offers the familiar and powerful SQL language, our codebase has nice C++ and JavaScript APIs for it, and it's already used in many places in the codebase.
SQLite may seem like a very appealing option when first designing a feature.
Many Firefox developers see SQLite as a default choice for storing any non-trivial amount of data, and this wiki explains why that view is incorrect. 5 How to Best Use SQLite If You Really Need To.3.7 Contending for Access to Storage with the Main Thread.