# 查询提示

> 英文标题：Query Hints
> 官网原文：https://typeorm.io/docs/performance-optimization/query-hints
> 文档版本：TypeORM v1.1
> 体例：英文原文（EN）与中文译文（ZH）逐块并列，共 5 块

---

<!-- EN -->
# Query Hints

<!-- ZH -->
# 查询提示

<!-- EN -->
Query Hints are instructions sent along with SQL queries, helping the database decide on more efficient execution strategies.

<!-- ZH -->
查询提示（Query Hints）是随 SQL 查询一起发送的指令，帮助数据库决定更高效的执行策略。

<!-- EN -->
Different RDBMS systems support different kinds of hints, such as suggesting index usage or choosing the appropriate JOIN type.

<!-- ZH -->
不同的 RDBMS 系统支持不同类型的提示，例如建议使用某个索引或选择合适的 JOIN 类型。

<!-- EN -->
```typescript
await dataSource.query(`
    SELECT /*+ MAX_EXECUTION_TIME(1000) */ *
    FROM user
    WHERE email = '[email protected]'
`)
```

<!-- ZH -->
```typescript
await dataSource.query(`
    SELECT /*+ MAX_EXECUTION_TIME(1000) */ *
    FROM user
    WHERE email = '[email protected]'
`)
```

<!-- EN -->
In the example above, `MAX_EXECUTION_TIME(1000)` instructs MySQL to stop the query if it takes more than 1 second.

<!-- ZH -->
在上面的示例中，`MAX_EXECUTION_TIME(1000)` 指示 MySQL 在查询耗时超过 1 秒时中止该查询。
