From the course: Advanced SQL for Data Science: Time Series

Unlock the full course today

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

Indexing data set 1: Time index only

Indexing data set 1: Time index only - SQL Tutorial

From the course: Advanced SQL for Data Science: Time Series

Start my 1-month free trial

Indexing data set 1: Time index only

- [Instructor] Now, continuing from where we left off in the last video, I'm just going to clear this select statement, I want to take a look at how indexes can help us improve our query performance when we're working with time series data. The first thing I'd like to do is get the average temperature by location ID, so let's create a select statement for that. And that'll be simply select, then we'll select the location ID, and the average temperature, which is temp_celcius. And we're going to select from time_series schema and the location_temp table. We have an aggregate function up here using average, so we're going to need a group by, so we'll group by location_id. Now, I don't really want the average right now, what I'm really interested in is understanding how PostgreSQL will execute that query. So, I'm going to put the explain command before the select statement and now when I execute, instead of getting the results of the query, I actually get the explain plan. Let's take a…

Contents