The following helps to analyze the frequency of each key operation.
- In Redshift run:
select * from stl_query where starttime::date='2019-12-05' and userid<>1 order by starttime,query;
and export it to stl_query.csv
- In bash, execute:
cat stl_query.csv | cut -f7 | sed -e 's/[[:space:]]*$//' | while read a
do
echo $a | egrep -i -o 'select|delete|insert|copy|unload|vacuum|analyze|alter|create|drop' | head -1
done | tr '[:upper:]' '[:lower:]'| sort | uniq -c
Note: Key operation is defined as the first SQL DML/DDL command found in a SQL Statement