SQL ordered by Elapsed Time 脚本

--提取&beg_snap 、&end_snap
select * from dba_hist_snapshot x ;

--提取&dbid
select * from v$database;

--提取$inst_num
select * from v$instance;

运行的时候输入上面的值(如果需要输入多次,那么输入同样值即可)

select
from (select round(nvl((sqt.elap / 1000000), to_number(null)),2) "Elapsed Time (s)",
round( nvl((sqt.cput / 1000000), to_number(null)),2) "CPU Time (s)",
sqt.exec, round(decode(sqt.exec, 0, to_number(null),
(sqt.elap / sqt.exec / 1000000)),2) "Elap per Exec (s)",
round((100
(sqt.elap / (select sum(e.value) - sum(b.value)
from dba_hist_sys_time_model b,
dba_hist_sys_time_model e
where b.snap_id = &beg_snap and
e.snap_id = &end_snap and
b.dbid = &dbid and
e.dbid = &dbid and
b.instance_number = &inst_num and
e.instance_number = &inst_num and
e.stat_name = 'DB time' and
b.stat_name = 'DB time'))) ,2) norm_val ,
sqt.sql_id,
decode(sqt.module, null, null, 'Module: ' || sqt.module) SqlModule,
nvl(to_nchar(SUBSTR(st.sql_text,1,2000)) , (' SQL Text Not Available ')) SqlText
from ( select sql_id,
max(module) module,
sum(elapsed_time_delta) elap,
sum(cpu_time_delta) cput,
sum(executions_delta) exec
from dba_hist_sqlstat
where dbid = &dbid and
instance_number = &inst_num and
&beg_snap < snap_id and
snap_id <= &end_snap
group by sql_id ) sqt,
dba_hist_sqltext st
where st.sql_id(+) = sqt.sql_id and
st.dbid(+) = &dbid
order by nvl(sqt.elap, -1) desc,
sqt.sql_id)
where rownum < 65 and
(rownum <= 10 or norm_val > 1);

转载于:https://blog.51cto.com/2012ivan/2129322

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
To estimate the ordered probit model using Maximum Likelihood Estimation (MLE), you can use the "VGAM" package in R. Here is an example code: ```R # Load the "VGAM" package library(VGAM) # Load the data (in this example, we use the "Prestige" dataset) data(Prestige) # Define the dependent and independent variables y <- Prestige$prestige x1 <- Prestige$education x2 <- Prestige$income # Define the log-likelihood function for the ordered probit model loglik <- function(theta, y, X) { mu <- X %*% theta p <- pnorm(c(-Inf, mu[-length(mu)], Inf)) lp <- diff(p) lp[y == length(p)] <- p[y == length(p)] ll <- sum(log(lp)) return(-ll) } # Estimate the ordered probit model using MLE op <- vglm(y ~ x1 + x2, family = cumulative(parallel = TRUE), weights = rep(1, length(y)), control = list(maxit = 1000, trace = TRUE), initdata = data.frame("estimate" = c(0, 0, 0)), coef = TRUE, method = "BFGS", crit = 1e-6, loglik = loglik, X = cbind(1, x1, x2)) # Print the summary of the model summary(op) ``` In this example, we define the log-likelihood function for the ordered probit model, which takes the parameter vector `theta`, the dependent variable `y`, and the independent variables `X` as input and returns the negative log-likelihood. We then use the `vglm` function to estimate the model using MLE. The `family` argument specifies the cumulative link function, and the `weights` argument specifies the weighting scheme. The `initdata` argument specifies the initial values for the optimization procedure. The `loglik` argument specifies the log-likelihood function, and the `X` argument specifies the design matrix. Finally, we print the summary of the model using the `summary` function. Note that the exact code may vary depending on the dataset and software package used. Also, it is important to note that MLE can be more computationally intensive than other methods for estimating the ordered probit model.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值