IBM Maximo: SQL Queries: Difference between revisions
Line 70: | Line 70: | ||
group by extract(hour from (cast(starttime as timestamp))) | group by extract(hour from (cast(starttime as timestamp))) | ||
order by extract(hour from (cast(starttime as timestamp))) | order by extract(hour from (cast(starttime as timestamp))) | ||
= Login= | |||
== Logins nos últimos 2 dias == | |||
select * from logintracking | |||
where attemptresult='LOGIN' | |||
and attemptdate > sysdate - 2 | |||
== Listar os Logins por hora == | |||
select extract(hour from (cast(attemptdate as timestamp))) login_hour, count(*) num_login | |||
from logintracking | |||
where attemptresult='LOGIN' | |||
and attemptdate > sysdate - 10 | |||
group by extract(hour from (cast(attemptdate as timestamp))) | |||
order by extract(hour from (cast(attemptdate as timestamp))) | |||
= Ver também = | = Ver também = |
Revision as of 19:26, 8 November 2021
Performance
Maiores tabelas e atualização de estatísticas
Verificando as maiores tabelas e a atualização de estatísticas das tabelas.
select table_name, round((num_rows*avg_row_len)/1048576) tbsize, num_rows, last_analyzed from all_tables where owner='MAX' and num_rows>0 order by num_rows desc
resultado
table_name tbsize num_rows last_analyzed WOSTATUS 27442 306121780 24-SET-21 WORKORDER 65996 95582941 24-SET-21 ...
Mesmo que seu ambiente tenha pouca movimentação, atualizar as estatísticas é fundamental pra um funcionamento do ambiente com qualidade.
Relatórios
Listar os relatórios executados com maior tempo de duracao nos últimos 30 dias
select reportname, description, appname, lastrunduration, lastrundate from report where lastrunduration is not null and lastrundate > sysdate - 30 order by lastrunduration desc
Listar os relatórios mais executados nos últimos 30 dias
select reportname, appname, sum(runtime)/1000 tot_exec_time, count(*) num_exec, round(avg(runtime)/1000,3) avg_exec_time from reportusagelog where startdate > sysdate - 30 group by reportname, appname order by tot_exec_time desc
Listar os relatórios por hora
select extract(hour from (cast(startdate as timestamp))) exechour, round(sum(enddate-startdate)*24*60*60,3) exec_time from reportusagelog where startdate > sysdate - 30 group by extract(hour from (cast(startdate as timestamp))) order by extract(hour from (cast(startdate as timestamp)))
Outros exemplos
Crontasks
Listar as crontasks executados com maior tempo de duracao nos últimos 30 dias
select crontaskname, instancename, servername, (endtime-starttime)*24*60*60 exec_time, starttime from crontaskhistory where activity='ACTION' and starttime > sysdate - 30 order by exec_time desc
Listar as crontasks executados por hora
select extract(hour from (cast(starttime as timestamp))) exec_hour, round(sum(endtime-starttime)*24*60*60,3) exec_time from crontaskhistory where activity='ACTION' and starttime > sysdate - 30 group by extract(hour from (cast(starttime as timestamp))) order by extract(hour from (cast(starttime as timestamp)))
Login
Logins nos últimos 2 dias
select * from logintracking where attemptresult='LOGIN' and attemptdate > sysdate - 2
Listar os Logins por hora
select extract(hour from (cast(attemptdate as timestamp))) login_hour, count(*) num_login from logintracking where attemptresult='LOGIN' and attemptdate > sysdate - 10 group by extract(hour from (cast(attemptdate as timestamp)))
order by extract(hour from (cast(attemptdate as timestamp)))