IBM Maximo: SQL Queries: Difference between revisions

From Wiki
Line 111: Line 111:
[[Category:IBM Maximo]]
[[Category:IBM Maximo]]
[[Category:ibm-maximo-sql]]
[[Category:ibm-maximo-sql]]
[[Category:ibm-maximo-performance]]

Revision as of 12:28, 9 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.

Geral

Registros por Ano

select yList.year y,
(select count(*) from workorder where extract(year from reportdate)=yList.year) c_workorder,
(select count(*) from wfinstance where extract(year from starttime)=yList.year) c_wfinstance,
(select count(*) from ticket where extract(year from reportdate)=yList.year) c_ticket,
(select count(*) from po where extract(year from orderdate)=yList.year) c_po,
(select count(*) from matrectrans where extract(year from transdate)=yList.year) c_matrectrans,
(select count(*) from servrectrans where extract(year from transdate)=yList.year) c_servrectrans
from (select column_value as year FROM table(sys.odcivarchar2list('2020','2021'))) yList
group by yList.year
order by yList.year;

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)))

Ver também