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.

v1.1.2 2022-02-07 11:12 UTC

This package is auto-updated.

Last update: 2024-05-05 00:17:19 UTC


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