ggergo/sqlindexhintbundle

Doctrine SqlWalker 扩展,用于在 MySQL 上使用 DQL 应用 USE INDEX 和 FORCE INDEX 提示。与 createQuery 和 createQueryBuilder 都兼容。

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

This package is auto-updated.

Last update: 2024-09-05 01:03:41 UTC


README

Doctrine SqlWalker 扩展,用于在 MySQL 上使用 DQL 应用 USE INDEXFORCE INDEX 提示。与 createQuery()createQueryBuilder() 都兼容。可以为每个 DQL 表别名词设置不同的索引提示。

入门指南

示例

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

安装

使用 Composer 需要,例如:

composer require ggergo/sqlindexhintbundle