esplora/spire

Easy Tools for Production Environment of Laravel SQLite Database

0.0.2 2024-03-26 23:59 UTC

This package is auto-updated.

Last update: 2024-04-27 00:12:20 UTC


README

Spire is a Laravel package designed to provide easy tools specifically tailored for optimizing SQLite databases in production environments.

Installation

To install Spire into your Laravel project, you can use Composer:

composer require esplora/spire

Usage

Once installed, you can utilize Spire's commands via the Artisan CLI.

Commands

Enable WAL Journal

To enable WAL journal on SQLite databases for performance optimization:

php artisan sqlite:wal-enable

Enabling WAL journaling can enhance database concurrency, reduce contention, and improve overall database performance, especially in high-traffic production environments.

Optimize Database

To optimize the SQLite database by running PRAGMA optimize:

php artisan sqlite:optimize

This combined optimization process ensures comprehensive optimization of the database file, resulting in improved performance and efficient storage utilization.

Run VACUUM

To optimize the SQLite database by running VACUUM:

php artisan sqlite:vacuum

VACUUM rebuilds the database file, reclaims unused disk space, and can help to improve database performance by optimizing storage utilization.

Schedule

For efficient database maintenance, it's highly recommended to schedule some of these commands as cron jobs. For instance, you can optimize the SQLite database periodically by adding a cron job to your scheduler:

// Optimize SQLite database every minute,
// see https://www.sqlite.org/pragma.html#pragma_optimize
$schedule->command('sqlite:optimize')->everyMinute();