From the course: Advanced SQL for Data Scientists

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Optimize a query using an explain plan

Solution: Optimize a query using an explain plan

From the course: Advanced SQL for Data Scientists

Start my 1-month free trial

Solution: Optimize a query using an explain plan

(upbeat music) - [Instructor] Now the first thing we'd want to do if we're trying to understand query performance is to run an explain plan on the query. That'll give us a breakdown of the steps that are actually being executed. Now, as you're looking at those steps, some things you might want to keep an eye out for are things like a full table scans or sequence scans, where we're scanning large amounts of data. That's often an opportunity for creating indexes. Also, you want to assess how the indexes are used with joins. So in particular, if you think that an index should be used on a particular join, and if it's not being used, then that may mean the index was dropped, or there's some other reason the index isn't being used, but it's something worth investigating. And we also want to look for opportunities to filter the dataset side. You know, a fast running query is a query that doesn't have to look at a lot of…

Contents