PHPackages                             vpominchuk/laravel-mysql-use-index-scope - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. vpominchuk/laravel-mysql-use-index-scope

ActiveLibrary[Database &amp; ORM](/categories/database)

vpominchuk/laravel-mysql-use-index-scope
========================================

A super simple package allowing for use MySQL `USE INDEX` and `FORCE INDEX` statements

v1.0.8(7mo ago)41595.7k↓49.5%7[1 issues](https://github.com/vpominchuk/laravel-mysql-use-index-scope/issues)MITPHPPHP ^7.4|^8.0

Since Sep 12Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/vpominchuk/laravel-mysql-use-index-scope)[ Packagist](https://packagist.org/packages/vpominchuk/laravel-mysql-use-index-scope)[ Docs](https://github.com/vpominchuk/laravel-mysql-use-index-scope)[ RSS](/packages/vpominchuk-laravel-mysql-use-index-scope/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (7)Dependencies (1)Versions (9)Used By (0)

[![](https://camo.githubusercontent.com/16a2637475322fb78bd7aaea2c7058f2bc3d5807bba47e6bae354daa4624c030/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304d7953514c253230555345253230494e4445582532304d6f64656c25323053636f70652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d76706f6d696e6368756b2532466c61726176656c2d6d7973716c2d7573652d696e6465782d73636f7065267061747465726e3d74657874757265267374796c653d7374796c655f31266465736372697074696f6e3d416c6c6f77696e672b666f722b7573652b4d7953514c2b5553452b494e4445582b616e642b464f5243452b494e4445582b73746174656d656e7473266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/16a2637475322fb78bd7aaea2c7058f2bc3d5807bba47e6bae354daa4624c030/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304d7953514c253230555345253230494e4445582532304d6f64656c25323053636f70652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d76706f6d696e6368756b2532466c61726176656c2d6d7973716c2d7573652d696e6465782d73636f7065267061747465726e3d74657874757265267374796c653d7374796c655f31266465736372697074696f6e3d416c6c6f77696e672b666f722b7573652b4d7953514c2b5553452b494e4445582b616e642b464f5243452b494e4445582b73746174656d656e7473266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

[![Latest Version on Packagist](https://camo.githubusercontent.com/659e2e456f68cf2271ac6e0f98824bc8d21d0a65b3416dfd555f3f5672084dc9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76706f6d696e6368756b2f6c61726176656c2d6d7973716c2d7573652d696e6465782d73636f70652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vpominchuk/laravel-mysql-use-index-scope)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/36638ef61a1e6a9344662cf834e1c2d0eec6728e44ad554d9660c10acb471f77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76706f6d696e6368756b2f6c61726176656c2d6d7973716c2d7573652d696e6465782d73636f70652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vpominchuk/laravel-mysql-use-index-scope)

Laravel MySQL Use Index Scope
=============================

[](#laravel-mysql-use-index-scope)

A super simple package allowing for use MySQL `USE INDEX` and `FORCE INDEX` statements.

Requirements
------------

[](#requirements)

- PHP `^7.4 | ^8.0`
- Laravel 6, 7, 8, 9, 10, 11, and 12

Installation
------------

[](#installation)

`composer require vpominchuk/laravel-mysql-use-index-scope`

Usage
-----

[](#usage)

Simply reference the required trait in your model:

### Model:

[](#model)

```
    use VPominchuk\ModelUseIndex;

    class MyModel extends Model
    {
        use ModelUseIndex;
    }
```

### Anywhere in the code:

[](#anywhere-in-the-code)

```
    $builder = MyModel::where('name', $name)->where('age', $age)->
        useIndex($indexName)->...
```

### Database table structure:

[](#database-table-structure)

You need to create a named index with required name. For example:

Laravel Migration:

```
    $table->index(['name', 'age'], 'user_age_index');
```

Available methods
-----------------

[](#available-methods)

#### `useIndex($indexName)`

[](#useindexindexname)

Tells MySQL to use an index if it possible.

#### `forceIndex($indexName)`

[](#forceindexindexname)

Force MySQL to use an index if it possible.

#### `ignoreIndex($indexName)`

[](#ignoreindexindexname)

Ask MySQL to ignore an index if it possible.

Security
--------

[](#security)

If you discover any security related issues, please use the issue tracker.

Credits
-------

[](#credits)

- [Vasyl Pominchuk](https://github.com/vpominchuk)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance63

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 73.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~219 days

Recently: every ~277 days

Total

8

Last Release

222d ago

PHP version history (2 changes)v1.0.0PHP ^7.4 | ^8.0

v1.0.7PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4194395?v=4)[Vasyl](/maintainers/vpominchuk)[@vpominchuk](https://github.com/vpominchuk)

---

Top Contributors

[![vpominchuk](https://avatars.githubusercontent.com/u/4194395?v=4)](https://github.com/vpominchuk "vpominchuk (14 commits)")[![AJenbo](https://avatars.githubusercontent.com/u/204594?v=4)](https://github.com/AJenbo "AJenbo (2 commits)")[![dkmonaghan](https://avatars.githubusercontent.com/u/920215?v=4)](https://github.com/dkmonaghan "dkmonaghan (1 commits)")[![ijalnasution](https://avatars.githubusercontent.com/u/17308059?v=4)](https://github.com/ijalnasution "ijalnasution (1 commits)")[![issakujitsuk](https://avatars.githubusercontent.com/u/12658523?v=4)](https://github.com/issakujitsuk "issakujitsuk (1 commits)")

---

Tags

laravellaravel-eloquentlaravel-eloquent-modelslaravel-frameworkmysqlphplaravellaravel mysqllaravel mysql use indexlaravel mysql force index

### Embed Badge

![Health badge](/badges/vpominchuk-laravel-mysql-use-index-scope/health.svg)

```
[![Health](https://phpackages.com/badges/vpominchuk-laravel-mysql-use-index-scope/health.svg)](https://phpackages.com/packages/vpominchuk-laravel-mysql-use-index-scope)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.7k](/packages/illuminate-database)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[lemaur/eloquent-publishing

218.1k1](/packages/lemaur-eloquent-publishing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
