![]() ![]() For example: SELECT * FROM (SELECT * FROM t) t1, (SELECT * FROM t) t2 The first category of hints takes effect in the scope of query blocks, such as /*+ HASH_AGG() */ the second category of hints takes effect in the whole query, such as /*+ MEMORY_QUOTA(1024 MB)*/.Įach query or sub-query in a statement corresponds to a different query block, and each query block has its own name. The comments do not take effect, and no warning is reported.Ĭurrently, TiDB supports two categories of hints, which are different in scope. If the comments do not follow behind the specified keywords, they will be treated as common MySQL comments. Similarly, TiDB will at most return a warning if a hint is not applicable. This is because hints are intended to have only a hint (suggestion) semantic to query execution. How optimizer hints affect query execution plans can be observed in the output of EXPLAIN and EXPLAIN ANALYZE.Īn incorrect or incomplete hint will not result in a statement error. For example, the following query uses three different hints: SELECT /*+ USE_INDEX(t1, idx1), HASH_AGG(), HASH_JOIN(t1) */ count(*) FROM t t1, t t2 WHERE t1.a = t2.b Multiple hints can be specified by separating with commas. Optimizer hints are not currently supported for INSERT statements. */ comments following the SELECT, UPDATE or DELETE keyword in a SQL statement. ![]() Optimizer hints are case insensitive and specified within /*+. If the tables you use are not in the same database, refer to the instructions to explicitly specify the database name. The examples in this document are all tables in the same database. Tidb> SELECT /*+ READ_FROM_STORAGE(TIFLASH) */ t1.a FROM test1.t t1, test2.t t2 WHERE t1.a = t2.a Tidb> SELECT /*+ HASH_JOIN(test2.t2, t) */ * FROM t, test2.t2 | Warning | 1815 | There are no matching table names for (t2) in optimizer hint /*+ HASH_JOIN(t2, t) */ or /*+ TIDB_HJ(t2, t) */. For example: tidb> SELECT /*+ HASH_JOIN(t2, t) */ * FROM t, test2.t2 If the table you want to hint is not in the database specified by USE DATABASE, you need to specify the database name explicitly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |