EXPLAINing query behavior
Many times, queries have a different execution plan than you might expect. Earlier in the course, you ran a query to get all the December readings for air_temp
in Coffee County for the regular report type FM-15
. You used a CTE to limit it to the dates and then a select statement to filter the report types so it would be easy to shift timelines via the CTE. Let's look at an explanation of that statement.
This exercise is part of the course
Introduction to Redshift
Exercise instructions
- Run
EXPLAIN
on the entire statement. - Update the
temp_reading
condition to be between Nov 1st and 30th of 2023.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Explain the entire statement
___ WITH temp_readings as (
SELECT date,
hourlydrybulbtemperature AS air_temp,
report_type
FROM public_intro_redshift.coffee_county_weather
-- Set it to the proper dates in November 2023
WHERE date BETWEEN ___ AND ___
)
SELECT date,
air_temp
FROM temp_readings
WHERE report_type = 'FM-15';