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 2: Time and type Indexing

Indexing data set 2: Time and type Indexing - SQL Tutorial

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

Start my 1-month free trial

Indexing data set 2: Time and type Indexing

- [Instructor] Let's do some querying and creating indexes on utilization table we just created. So let's start with a basic SELECT statement. Now in this case, let's SELECT the server ID and the average CPU utilization. This is from the time_series schema and the utilization table. And let's restrict this to a single day. So we'll say WHERE the event_time is BETWEEN March 5th, 2019 and March 6th, 2019. And we'll want to GROUP BY server ID. And we also- Again, we're not so much interested in the data, as much as the EXPLAIN plans. So I'm just going to put EXPLAIN in here. And what we see, is we have a query that's costing about 3800, 3900 computational units. Now, let's see if we can speed that up a little bit by creating an index. So I'm going to insert another statement to create INDEX. And we'll call this one, idx_util_time_serv, and this will be on time_series.utilization, and it will first be on event_time, and then server_id. So we're at 3876 computational units without an…

Contents