From 88684813dcc6df4f47feb9de218220c8698aea00 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Fri, 9 Aug 2024 10:45:40 +0800 Subject: [PATCH] sys var: add more contents to `tidb_remove_orderby_in_subquery` (#18530) --- system-variables.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system-variables.md b/system-variables.md index f52d7083c9c1a..27d4fec816dbc 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4953,6 +4953,8 @@ SHOW WARNINGS; - Type: Boolean - Default value: Before v7.2.0, the default value is `OFF`. Starting from v7.2.0, the default value is `ON`. - Specifies whether to remove `ORDER BY` clause in a subquery. +- In the ISO/IEC SQL standard, `ORDER BY` is mainly used to sort the results of top-level queries. For subqueries, the standard does not require that the results be sorted by `ORDER BY`. +- To sort subquery results, you can usually handle it in the outer query, such as using the window function or using `ORDER BY` again in the outer query. Doing so ensures the order of the final result set. ### tidb_replica_read New in v4.0