Skip to content

Commit

Permalink
beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tanelpoder committed Jun 18, 2024
1 parent 2482d82 commit c0f4e2c
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions npstat.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.

--------------------------------------------------------------------------------
--
-- File name: sgastatx
-- Purpose: Show shared pool stats by sub-pool from X$KSMSS
--
-- Author: Tanel Poder
-- Copyright: (c) http://www.tanelpoder.com
--
-- Usage: @sgastatx <statistic name>
-- @sgastatx "free memory"
-- @sgastatx cursor
--
-- Other: The other script for querying V$SGASTAT is called sgastat.sql
--
--
--
--------------------------------------------------------------------------------

COL sgastatx_subpool HEAD SUBPOOL FOR a30

PROMPT
PROMPT -- All allocations:

SELECT
'numa pool'
, ksmnssidx
, ksmnsprocgrp
-- , ksmnsnam
, ksmssgbl
, sum(CASE WHEN ksmnsnam = 'free memory' THEN 0 ELSE ksmnslen END) mem_used
, sum(CASE WHEN ksmnsnam = 'free memory' THEN ksmnslen ELSE 0 END) mem_free
, sum(ksmnslen) mem_total
from x$ksmns
group by
'numa pool'
, ksmnssidx
, ksmnsprocgrp
-- , ksmnsnam
, ksmssgbl
order by
1,2,3
/

SELECT
'numa pool'
, ksmnssidx
, ksmnsprocgrp
, ksmnsnam
, ksmssgbl
, sum(ksmnslen)
from x$ksmns
where lower(ksmnsnam) like lower('%&1%')
group by
'numa pool'
, ksmnssidx
, ksmnsprocgrp
, ksmnsnam
, ksmssgbl
order by
1,2,3
/

-- SELECT
-- 'shared pool ('||NVL(DECODE(TO_CHAR(ksmdsidx),'0','0 - Unused',ksmdsidx), 'Total')||'):' sgastatx_subpool
-- , SUM(ksmsslen) bytes
-- , ROUND(SUM(ksmsslen)/1048576,2) MB
-- FROM
-- x$ksmss
-- WHERE
-- ksmsslen > 0
-- --AND ksmdsidx > 0
-- GROUP BY ROLLUP
-- ( ksmdsidx )
-- ORDER BY
-- sgastatx_subpool ASC
-- /
--
-- BREAK ON sgastatx_subpool SKIP 1
-- PROMPT -- Allocations matching "&1":
--
-- SELECT
-- subpool sgastatx_subpool
-- , name
-- , SUM(bytes)
-- , ROUND(SUM(bytes)/1048576,2) MB
-- FROM (
-- SELECT
-- 'shared pool ('||DECODE(TO_CHAR(ksmdsidx),'0','0 - Unused',ksmdsidx)||'):' subpool
-- , ksmssnam name
-- , ksmsslen bytes
-- FROM
-- x$ksmss
-- WHERE
-- ksmsslen > 0
-- AND LOWER(ksmssnam) LIKE LOWER('%&1%')
-- )
-- GROUP BY
-- subpool
-- , name
-- ORDER BY
-- subpool ASC
-- , SUM(bytes) DESC
-- /

BREAK ON sgastatx_subpool DUP

0 comments on commit c0f4e2c

Please sign in to comment.