User guide

The information on the Plan tab is analogous to running the EXPLAIN command in the database. The
EXPLAIN command examines your query text, and returns the query plan.You use this information to
evaluate queries, and revise them for efficiency and performance if necessary. The EXPLAIN command
doesn’t actually run the query.
The following example shows a query that returns the top five sellers in San Diego, based on the number
of tickets sold in 2008, and the query plan for that query.
explain
select sellerid, username, (firstname ||' '|| lastname) as name,
city, sum(qtysold)
from sales, date, users
where sales.sellerid = users.userid
and sales.dateid = date.dateid
and year = 2008
and city = 'San Diego'
group by sellerid, username, name, city
order by 5 desc
limit 5;
For more information about understanding the explain plan, go to Analyzing the Explain Plan in the
Amazon Redshift Database Developer Guide.
When you actually run the query (omitting the EXPLAIN command), the engine might find ways to optimize
the query performance and change the way it processes the query. The actual performance data for the
query is stored in the system views, such as SVL_QUERY_REPORT and SVL_QUERY_SUMMARY.
The Amazon Redshift console uses a combination of STL_EXPLAIN, SVL_QUERY_REPORT, and other
system views and tables to present the actual query performance and compare it to the explain plan for
the query. This information appears on the Actual tab. If you see that the explain plan and the actual
query execution steps differ, you might need to perform some operations in the database, such as
ANALYZE, to update statistics and make the explain plan more effective.
Additionally, sometimes the query optimizer breaks complex SQL queries into parts and creates temporary
tables with the naming convention volt_tt_guid to process the query more efficiently. In this case, both
the explain plan and the actual query execution summary apply to the last statement that was run.You
can review previous query IDs to see the explain plan and actual query execution summary for each of
the corresponding parts of the query.
API Version 2012-12-01
191
Amazon Redshift Management Guide
Viewing Query Performance Data