From the course: Advanced SQL for Query Tuning and Performance Optimization
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Hints to the Query Optimizer - SQL Tutorial
From the course: Advanced SQL for Query Tuning and Performance Optimization
Hints to the Query Optimizer
- [Instructor] Hints are suggestions to a query plan builder. Some databases allow you to specify hints in line with the SQL code. Now, these inline suggestions are outside of normal SQL statements, they're are extra-SQL statements, and this practice really pushes the boundary between declarative and procedural code. Now, some data spaces support hints, like Oracle, MySQL and SQL Server. However, Postgres takes a different approach. Postgres uses commands to change the behavior of the query plan builder. For example, with the SET enable commands you can prevent the use of hash joins, or you can make sure that nested loops are enabled. All join options are available by default, so you don't need to do anything if you want to have all three enabled. Now, some caveats, you want to be careful anytime you're using hints in other databases or changing the configuration of the query plan builder. Oftentimes, it's better…
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Using common table expressions to avoid repetitive computation2m 11s
-
(Locked)
Hints to the Query Optimizer1m 43s
-
(Locked)
Parallel query execution2m 6s
-
(Locked)
Improving cache utilization2m 20s
-
(Locked)
Miscellaneous tips2m 21s
-
(Locked)
Challenge: Design a common table expression24s
-
(Locked)
Solution: Design a common table expression18s
-
(Locked)
-