Sort operator in execution plans
Execution plans can tell us if and where a query used an internal sorting operation. Internal sorting is often required when using an operator in a query that checks for and removes duplicate rows.
You are given an execution plan of a query that returns all cities listed in the Earthquakes
database. The query appends queries from the Nations
and Cities
tables. Use the following execution plan to determine if the appending operator used is UNION
or UNION ALL
This is a part of the course
“Improving Query Performance in SQL Server”
Exercise instructions
- Add the operator that the execution plan indicates was used to append the queries.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT CityName AS NearCityName,
CountryCode
FROM Cities
___ -- Append queries
SELECT Capital AS NearCityName,
Code2 AS CountryCode
FROM Nations;
This exercise is part of the course
Improving Query Performance in SQL Server
In this course, students will learn to write queries that are both efficient and easy to read and understand.
Students are introduced to how STATISTICS TIME, STATISTICS IO, indexes, and executions plans can be used in SQL Server to help analyze and tune query performance.
Exercise 1: Time statisticsExercise 2: STATISTICS TIME in queriesExercise 3: STATISTICS TIME resultsExercise 4: Page read statisticsExercise 5: STATISTICS IO: Example 1Exercise 6: STATISTICS IO: Example 2Exercise 7: STATISTICS IO comparisonExercise 8: IndexesExercise 9: Test your knowledge of indexesExercise 10: Clustered indexExercise 11: Execution plansExercise 12: Sort operator in execution plansExercise 13: Test your knowledge of execution plansExercise 14: Query performance tuning: final notesWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.