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

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