A super simple package allowing for use MySQL USE INDEX
and FORCE INDEX
statements.
- PHP
^7.4 | ^8.0
- Laravel 6, 7, 8, 9, 10, and 11
composer require vpominchuk/laravel-mysql-use-index-scope
Simply reference the required trait in your model:
use VPominchuk\ModelUseIndex;
class MyModel extends Model
{
use ModelUseIndex;
}
$builder = MyModel::where('name', $name)->where('age', $age)->
useIndex($indexName)->...
You need to create a named index with required name. For example:
Laravel Migration:
$table->index(['name', 'age'], 'user_age_index');
Tells MySQL to use an index if it possible.
Force MySQL to use an index if it possible.
Ask MySQL to ignore an index if it possible.
If you discover any security related issues, please use the issue tracker.
The MIT License (MIT). Please see License File for more information.