ggergo / sqlindexhintbundle
Doctrine SqlWalker extension to apply USE INDEX and FORCE INDEX hints using DQL on top of MySql. Works with both createQuery and createQueryBuilder.
Installs: 374 176
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 1
Forks: 8
Open Issues: 1
Requires
- php: ^7.1 || ^8.0
- doctrine/orm: ^2.6
Requires (Dev)
- phpunit/phpunit: ^7
README
Doctrine SqlWalker extension to apply USE INDEX
and FORCE INDEX
hints using DQL on top of MySQL.
Works with both createQuery()
and createQueryBuilder()
.
You can set different index hints per DQL table aliases.
Getting Started
Example:
use Ggergo\SqlIndexHintBundle\SqlIndexWalker; use Doctrine\ORM\Query; // ... $query = '...'; $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, SqlIndexWalker::class); $query->setHint(SqlIndexWalker::HINT_INDEX, [ 'your_dql_table_alias' => 'FORCE INDEX FOR JOIN (your_composite_index) FORCE INDEX FOR ORDER BY (PRIMARY)', 'your_another_dql_table_alias' => 'FORCE INDEX (PRIMARY)', // ... ]);
Installing
Require with Composer, i.e.:
composer require ggergo/sqlindexhintbundle