Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » UltraLite - Database Management and Developer Guide » UltraLite database reference » UltraLite connection parameters

UltraLite CACHE_SIZE connection parameter

Defines the initial size of the database cache. UltraLite manages the cache size automatically, so setting this parameter should not be necessary.

For Android devices, you can use Configuration.setPageSize as an alternative to setting this connection parameter.

CACHE_SIZE=number{ k | m }

The default initial cache size is determined by the amount of memory available on your system and the size of the database.


The cache_size connection parameter specifies the initial amount of memory to allocate for the file cache. This cache is used to hold recently used pages from the database file in memory so they can be accessed quickly when needed again, and also to collect multiple modifications to a page before writing it back to storage. Accessing a page from the cache is many times faster than reading from storage. Writing to storage is more expensive, so grouping multiple modifications in a single write is important for performance. Encrypted databases also benefit from the cache because decryption occurs only when the page is loaded into the cache, and encryption occurs before the page is written back to storage. If the cache is sufficiently large, the overhead of encryption becomes negligible.

As an example of cache usage, consider synchronization. While UltraLite is receiving a download, the rows are inserted into the database, and referential integrity checks are performed. When inserted, the rows are also indexed; they are added to each index on the table. So, while synchronizing, the cache tends to hold the pages where the new rows are stored, as well as the index pages for the current table. Synchronization performance depends on whether the cache is large enough to contain an appropriate working set of pages for a table being synchronized. If the cache is too small, row inserts may require repeated reads of index pages from storage, incurring a noticeable performance penalty over the case when the required index pages fit in the cache.

By default, the size is in bytes. Use k or m to specify units of kilobytes or megabytes.

If you exceed the permissible maximum cache size, it is automatically replaced with your platform's upper cache size limit.

Any leading or trailing spaces in parameter values are ignored. This connection parameter's value cannot include leading single quotes, leading double quotes, or semicolons.


The following connection string fragment sets the cache size to 20 MB.