GitHub - 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.
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.
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)', // ... ]);