学习动态性能表 第十三篇--V$OPEN_CURSOR

 

学习动态性能表

13--V$OPEN_CURSOR 

  本视图列出session打开的所有cursors,很多时候都将被用到,比如:你可以通过它查看各个session打开的cursor数。

  当诊断系统资源占用时,它常被用于联接v$sqlareav$sql查询出特定SQL(高逻辑或物理I/O)。然后,下一步就是找出源头。在应用环境,基本都是同一类用户登陆到数据库(V$SQLAREA中拥有相同的PARSING_USER_ID),而通过这个就可以找出它们的不同。V$SQLAREA中的统计项在语句完全执行后被更新(并且从V$SESSION.SQL_HASH_VALUE中消失)。因此,你不能直接找到session除非语句被再次执行。不过如果sessioncursor仍然打开着,你可以通过v$open_cursor找出执行这个语句的session

V$OPEN_CURSOR中的连接列

 

Column                                    View                                                Joined Column(s)

-----------------------------            ----------------------------------------              -----------------------------

HASH_VALUE, ADDRESS                   V$SQLAREA, V$SQL, V$SQLTEXT             HASH_VALUE, ADDRESS

SID                                                          V$SESSION                                                      SID

示例:

1.找出执行某语句的session

SELECT hash_value, buffer_gets, disk_reads

FROM V$SQLAREA

WHERE disk_reads > 1000000

ORDER BY buffer_gets DESC;

HASH_VALUE BUFFER_GETS DISK_READS

---------- ----------- ----------

1514306888   177649108    3897402

 478652562    63168944    2532721

 360282550    14158750    2482065

3 rows selected.

SQL> SELECT sid FROM V$SESSION WHERE sql_hash_value = 1514306888 ;

no rows selected

--直接通过hash_value查找v$session,没有记录

SQL> SELECT sid FROM V$OPEN_CURSOR WHERE hash_Value = 1514306888 ;

 SID

-----

 1125

 233

 935

 1693

 531

5 rows selected.

--通过hash_valuev$open_cursor中查找sid(只有在sessioncursor仍然打开的情况下才有可能找到)

2.列出拥有超过400cursorsessionID

SQL> SELECT sid, count(0) ct FROM v$open_cursor

GROUP BY sid HAVING COUNT(0) > 400 ORDER BY ct desc;

事实上,v$open_cursor是一个相当常用的视图,特别是web开发应用的时候。仅通过它一个视图你就能分析出当前的连接情况,主要执行语句等。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
转python写法:#!/bin/sh time_stamp=`date +%s` function CheckStop() { if [ $? -ne 0 ]; then echo "execute fail, error on line_no:"$1" exit!!!" exit fi } function GenEcdsaKey() { ec_param_file_path="/tmp/ec_param.pem."$time_stamp openssl ecparam -out $ec_param_file_path -name prime256v1 -genkey CheckStop $LINENO openssl genpkey -paramfile $ec_param_file_path -out $1 CheckStop $LINENO openssl pkey -in $1 -inform PEM -out $2 -outform PEM -pubout CheckStop $LINENO rm $ec_param_file_path echo "gen_ecdsa_key succ prikey_path:"$1" pubkey_path:"$2 } function GenEcdsaSign() { ec_sign_info_file="/tmp/ec_sign_info_file."$time_stamp ec_sign_info_sha256="/tmp/ec_sign_info_sha256."$time_stamp ec_binary_sign_file="/tmp/ec_binary_sign_file."$time_stamp echo -n "$1"_"$2" > $ec_sign_info_file openssl dgst -sha256 -binary -out $ec_sign_info_sha256 $ec_sign_info_file CheckStop $LINENO openssl pkeyutl -sign -in $ec_sign_info_sha256 -out $ec_binary_sign_file -inkey $3 -keyform PEM CheckStop $LINENO openssl base64 -e -in $ec_binary_sign_file -out $4 CheckStop $LINENO rm $ec_sign_info_file $ec_sign_info_sha256 $ec_binary_sign_file echo "gen_ecdsa_sign succ sign_file_path:"$4 } function VerifyEcdsaSign() { ec_sign_info_file="/tmp/ec_sign_info_file."$time_stamp ec_sign_info_sha256="/tmp/ec_sign_info_sha256."$time_stamp ec_binary_sign_file="/tmp/ec_binary_sign_file."$time_stamp echo -n "$1"_"$2" > $ec_sign_info_file openssl dgst -sha256 -binary -out $ec_sign_info_sha256 $ec_sign_info_file CheckStop $LINENO openssl base64 -d -in $4 -out $ec_binary_sign_file CheckStop $LINENO openssl pkeyutl -verify -in $ec_sign_info_sha256 -sigfile $ec_binary_sign_file -pubin -inkey $3 -keyform PEM rm $ec_sign_info_file $ec_sign_info_sha256 $ec_binary_sign_file } function Usage() { echo "Usage:" echo "mmiot_ecdsa_sign.sh gen_ecdsa_key <private_key_file_path> <public_key_file_path>" echo "mmiot_ecdsa_sign.sh gen_ecdsa_sign <product_id> <sn> <private_
05-31

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值