In Panoply, you can retrieve the past queries you have executed by running a query against the STL_QUERY
system table. This table returns execution information about the database queries you've run in the past. It's also one of the many system tables you can query in Panoply.
Below is a sample query that lists the five most recent queries. Use the Panoply Workbench tool or any SQL client tool to execute it.
SELECT query, label, database, trim(querytxt) AS sqlquery FROM stl_query ORDER BY starttime DESC LIMIT 5;
Some notes to keep in mind when querying the STL_QUERY
table:
- The table only contains information about queries and does not log DDL-related commands (
CREATE TABLE
,DROP TABLE
, etc.). Check theSTL_DDLTEXT
system table regarding recorded DDL statements. - The table retains approximately two to five days of log history, depending on log usage and available disk space.
- The table also includes information about the current database where you executed the query with and currently connected user.
For a detailed explanation of the said system table, see the STL_QUERY reference article of the Amazon Redshift documentation.
Comments
0 comments
Please sign in to leave a comment.