快速檢查處理資料庫大量會話堵塞卡死情況

2021-10-03 06:47:56 字數 4096 閱讀 1870

–檢視連線等待數:

select

count(*

), event, wait_class

from **$session_wait

group

by event, wait_class

orderby1

desc

;

–檢視具體機器等待連線數

select t.machine,

count(1

)from **$session t

where t.event=

'latch: cache buffers chains'

group

by t.machine;

–查詢oracle的連線數

select

count(*

)from v$session

;

–查詢oracle的併發連線數

select

count(*

)from v$session

where

status

='active'

;

–檢視不同使用者的連線數

select username,

count

(username)

from v$session

where username is

notnull

group

by username;

–當前的連線數

select

count(*

)from v$process;

–可用連線數

select

value

from v$parameter where name =

'processes'

;

–檢視當前活動會話正執行的sql:

select b.sid,

b.machine,

b.username,

round((

(a.cpu_time / a.executions)

/100000),

10) cpu_etime,

a.executions,

a.sql_id,

a.sql_fulltext fullsql,

a.sql_text,

a.parse_calls,

a.cpu_time,

b.program,

-- a.buffer_gets,

'alter system kill session '

||''''

|| b.sid

|| ','

|| b.serial#

|| ''''

||';'

, b.client_info

from v$sql a, v$session b

where executions >

0and b.

status

='active'

and a.hash_value = b.sql_hash_value

and a.sql_id = b.sql_id

-- and b.username = 'hx_user'

-- and b.sql_id='27gff0m4jutv3'

--and ((cpu_time / executions) / 100000 >= 10)

order

by(cpu_time / executions)

desc

, a.buffer_gets desc

, a.executions desc

, a.sql_id;

–根據會話條件關聯查殺會話:

select

'kill -9 '

|| pp.spid

from v$session ss, v$process pp

where

status

='inactive'

and ss.paddr = pp.addr

and ss.program like

'%jdbc%'

and ss.username =

'db_wsbs'

;

–檢視表空間是否滿:

select t.tablespace_name,

to_char(

round

(t.tablespace_size *8/

1024

/1024,2

),'99990.00'

) sizes,

to_char(

round

(t.used_space *8/

1024

/1024,2

),'99990.00'

) used,

to_char(

round

((t.tablespace_size - t.used_space)*8

/1024

/1024,2

),'99990.00'

) free,

to_char(

round

(t.used_percent,2)

,'99990.00')||

'%' percents

from dba_tablespace_usage_metrics t

where t.tablespace_name notin(

'sysaux'

,'undotbs1'

,'undotbs2'

,'system'

,'cssbbfb'

)orderby2

desc

;

–檢視是否有鎖:

select decode(t.request,0,

'holder:'

,'waiter:')||

' inst_id:'

|| t.inst_id ||

', sid: '

|| t.sid sess,v.username,t.ctime,v.

status

, t.id1,v.sql_id, t.id2, t.lmode, t.request,

t.type

,v.status

,v.event,v.

type

,p.inst_id,p.spid,

'ps -ef|grep '

||p.spid,

'kill -9 '

||p.spid,v.program

from **$lock t,**$session v, **$process p

where

(t.id1, t.id2, t.

type)in

(select id1, id2,

type

from **$lock

where request >0)

and v.

type

<>

'background'

and v.inst_id=t.inst_id and t.sid=v.sid and p.addr = v.paddr and p.inst_id=v.inst_id

order

by id1, request;

c 快速 將大量資料插入資料庫

快速插入資料 主要思想是通過在客戶端把資料都快取在table中,然後利用sqlbulkcopy一次性把table中的資料插入到資料庫 public static void bulktodb datatable dt catch exception ex finally public static d...

c 快速 將大量資料插入資料庫

快速插入資料 主要思想是通過在客戶端把資料都快取在table中,然後利用sqlbulkcopy一次性把table中的資料插入到資料庫 public static void bulktodb datatable dt catch exception ex finally public static d...

達夢資料庫對會話的處理

查詢會話的一些資訊,可用於殺掉會話查詢sess id select a.sess id as 會話id,a.sql text as sql語句,a.state as 會話狀態,a.n used stmt as 當前會話使用控制代碼數量,a.curr sch as 當前模式,a.user name a...