Find last query executed by specific user in Redshift

Article for: Snowflake Teradata Vertica

Query below shows last queries executed by specific user.

Notes

Table containing query log retain them approximately for 2-5 days then they are removed.

Query

select usename as username,
       database,
       querytxt as query,
       starttime,
       endtime,
       case aborted
            when 1 then 'YES'
            else 'NO'
            end as aborted
from stl_query ql
join svl_user_info us
     on ql.userid = us.usesysid
where usename = 'dataedo' -- put username here
order by starttime desc;

Columns

  • username - name of user who executed query
  • database - name of database in which query was executed
  • query - query text
  • starttime - start time of a query
  • endtime - end time of a query
  • aborted - indicate wheter query was aborted

Rows

  • One row represents one query executed by specific user
  • Scope of rows: all queries saved in log for provided user
  • Ordered by start time of query

Sample results

sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.