A laravel package that optimizes mysql database tables.
OPTIMIZE TABLE statement is used to reorganize tables and compact any wasted space. The reorganized tables require less disk I/O to perform full table scans.
OPTIMIZE TABLE copies the data part of the table and rebuilds the indexes. The benefits come from improved packing of data within indexes, and reduced fragmentation within the tablespaces and on disk. The benefits vary depending on the data in each table. You may find that there are significant gains for some and not for others, or that the gains decrease over time until you next optimize the table. This operation can be slow if the table is large or if the indexes being rebuilt do not fit into the buffer pool. The first run after adding a lot of data to a table is often much slower than later runs.
For more details, please read the MySQL website on optimization techniques.
Via Composer
$ composer require zakriyarahman/laravel-mysql-optimize
This package provides default configuration variables. Publish configuration to your repository for custom configuration.
The default setting for the database is set to the environmental DB_DATABASE
variable.
$ artisan vendor:publish --provider="ZaksMySQLOptimierServiceProvider" --tag=config
Optimize the database tables with optional database and tables/s.
$ artisan db:optimize --database={DATABASE} --table={table[]}
Optimizes a default database (which is defined in the configuration of the package) with all the tables in that database. Publish the package configuration to the change defualt database settings.
$ artisan db:optimize
Optimizes a custom database separate from the default database configuration.
$ artisan db:optimize --database=database_test
Optimizes a set of tables only.
$ artisan db:optimize --table=table_1 --table=table_2
An exception is thrown when an argument such as table or database does not exists.
ZaksMySQLOptimierExceptionsDatabaseNotFoundException
ZaksMySQLOptimierExceptionsTableNotFoundException
$ composer test
Please see LICENSE here
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Please follow the following guides and code standards: