The combination of ORDER BY and LIMIT is commonly used in business queries to obtain a result set with a specific number of rows after sorting. The final query plan may require minimal data retrieval from the relevant tables, resulting in an efficient plan. Alternatively, it may involve reading all the data from the relevant tables, performing operations, and then returning only the necessary rows, which tends to be less efficient than the former approach. To optimize this scenario, it's crucial to understand the reasons behind the generation of these two types of plans and to employ various optimization methods to achieve a more efficient plan.
Overview
share
Previous topic