This package is a work-in-progress, therefore you should not use it in production - and always backup your database before requiring it through Composer.
This package provides a simple way to optimize your SQLite database in Laravel; it's a good starting point for production-ready SQLite databases. At the time of this writing, it applies the following settings:
βββββββββββββββββββββββββββββ¬ββββββββββββββ¬ββββββββββββ
β Setting β Value β Via β
βββββββββββββββββββββββββββββΌββββββββββββββΌββββββββββββ€
β PRAGMA auto_vacuum β incremental β Migration β
β PRAGMA journal_mode β WAL β Migration β
β PRAGMA page_size β 32768 β Migration β
β PRAGMA busy_timeout β 5000 β Runtime β
β PRAGMA cache_size β -20000 β Runtime β
β PRAGMA foreign_keys β ON β Runtime β
β PRAGMA incremental_vacuum β (enabled) β Runtime β
β PRAGMA mmap_size β 2147483648 β Runtime β
β PRAGMA temp_store β MEMORY β Runtime β
β PRAGMA synchronous β NORMAL β Runtime β
βββββββββββββββββββββββββββββ΄ββββββββββββββ΄ββββββββββββ
The settings are applied in two ways:
- Migration Stub - Applied via migration.
- Runtime Configuration - Applied at runtime, via service provider.
Requires PHP 8.2+, SQLite 3.46+ and Laravel 11.0+
You can install the package via Composer:
composer require nunomaduro/laravel-optimize-database
To get started optimizing your SQLite database, you need to run the following command:
php artisan db:optimize
At this point, the [Runtime] settings are applied automatically. However, you need to run the migration to apply the [Migration] settings:
php artisan migrate
Laravel Optimize Database was created by Nuno Maduro under the MIT license.