Is there any need to specify PRAGMA page_size = 4096 for a new mobile phone application with SQLite?

Viewed 145

For a Xamarin Mobile phone application, can someone explain what these three statements do and if they are really needed when creating a SQLite database:

    db.execute("PRAGMA page_size = 4096");
    db.execute("PRAGMA legacy_file_format = 0");
    db.execute("VACUUM");
1 Answers

The default page size has been 4k since version 3.12.0 from March 2016, so unless you're using an older version or a version compiled with a custom default page size (or a database originally created with such a version), there's no reason to set the size to 4k.

The legacy_file_format pragma is a no-op that does nothing. I don't know when this changed. The legacy file format is needed to create a database that can be read by versions before 3.3.0. It has defaulted to off since 3.7.10 from January 2012 but can still be enabled (or disabled on an existing legacy DB) via the C dbconfig API.

The VACUUM is needed on a populated database to make a page size change actually take effect.

So, to summarize: unless you're using really old outdated SQLite versions or non-standard compile time defaults, no, you don't need any of that.

Related