From the course: Advanced SQL for Query Tuning and Performance Optimization

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Merge join example

Merge join example

- [Instructor] We'll now see what a mergejoin looks like. We'll start with our directives, and we will disable the use of a hashjoin by setting enable_hashjoin to false, and we'll enable the mergejoin by setting the directive to true, and we'll paste in, once again, our query that we've been using, and again, we're going to look at the staff table, and from the staff table, we're going to return the id, last_name, and job_title, and from the company_regions table, we're going to return the country, so let's run this and see what a mergejoin looks like, and we'll just scroll over to the panel with our explain results, and what we'll see, starting at the top here, is, first of all, the mergejoin costs about 132 computational units, so this is definitely not the optimal plan, but that's okay. We are interested in understanding what the structure of a mergejoin looks like. Well, the first thing we'll see is that we're…

Contents