"Dan's Oracle7 Guide" - README.profile
Date: 20 Sep 1993 06:10:44 GMT
Message-ID: <DBIKLE.93Sep19231044_at_alumni.cco.caltech.edu>
Keywords: Oracle7
README.profile
CPU time Idle time Connect time I/O usage (Logical Reads) Memory usage (in each process's PGA) Number of sessions by each user
Example syntax for creating a profile is displayed below:
DROP PROFILE PR1
/
CREATE PROFILE PR1 LIMIT
CONNECT_TIME 12345 /* in minutes */ LOGICAL_READS_PER_CALL 12345 /* in data blocks */ LOGICAL_READS_PER_SESSION 123450/* in data blocks */ CPU_PER_CALL 12345600 /* in 1/100 sec */ CPU_PER_SESSION 12345600 /* in 1/100 sec */ IDLE_TIME 12345 /* in minutes */ PRIVATE_SGA 10M /* in bytes, kbytes, or mbytes */ SESSIONS_PER_USER 123 /* # sessions a user can run */ COMPOSITE_LIMIT 1234567000 /* expressed in "service units" */
/
CREATE USER BUFORD IDENTIFIED BY BUBBA
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE PR1
/
Or if BUFORD already exists, use this syntax:
ALTER USER BUFORD
PROFILE PR1
/
Altering a Profile
Changing a Resource Limit may be done with the ALTER PROFILE command. Example syntax for changing a Resource Limit is displayed below:
ALTER PROFILE PR1 LIMIT
CONNECT_TIME 123456
/
Unrestricting a Resource Limit
Changing a Resource Limit so that it is unlimited is accomplished via the syntax displayed below:
ALTER PROFILE PR1 LIMIT
CONNECT_TIME UNLIMITED
/
CONNECT_TIME
The queries displayed below may be used to gather information about the CONNECT_TIME resource after auditing has been enabled:
SELECT
USERNAME
,NVL (
(LOGOFF_TIME-TIMESTAMP)*24, 0 ) HOURS_CONNECT_TIME
FROM DBA_AUDIT_SESSION
ORDER BY USERNAME , NVL(LOGOFF_TIME-TIMESTAMP, 0) DESC
/
Example Results:
USERNAME HOURS_CONNECT_TIME
------------------------------ ------------------ OPS$DAN 7.09444444 OPS$DAN 5.70027778 OPS$DAN 3.68166667 OPS$DAN .5 OPS$DAN .388055556 OPS$DAN .211666667 OPS$DAN .162222222 OPS$DAN .099444444 OPS$DAN .078055556 OPS$DAN .077777778 OPS$DAN .043888889 OPS$DAN .001388889 OPS$DAN 0 OPS$DAN 0 SCOTT .008055556 SCOTT .002777778 SCOTT .002777778 SCOTT .001666667
SELECT
SUBSTR(USERNAME,1,11) USERNAME
,AVG(
NVL ( (LOGOFF_TIME-TIMESTAMP)*24, 0 )
) AVG_HOURS_CONNECT_TIME
,MAX(
NVL ( (LOGOFF_TIME-TIMESTAMP)*24, 0 )
) MAX_HOURS_CONNECT_TIME
FROM DBA_AUDIT_SESSION
GROUP BY USERNAME
/
Example Results:
USERNAME AVG_HOURS_CONNECT_TIME MAX_HOURS_CONNECT_TIME
----------- ---------------------- ----------------------
OPS$DAN .649424603 7.09444444
SCOTT .003819444 .008055556
LOGICAL_READS_PER_CALL
Gathering statistics on the LOGICAL_READS_PER_CALL resource is not apparent to the author. Statistics on the LOGICAL_READS_PER_SESSION resource, however, are easily available from the Audit Trail. Once the LOGICAL_READS_PER_SESSION resource limit has been determined by the DBA, he/she could decide that the LOGICAL_READS_PER_CALL resource should be 1/10 the value set for the LOGICAL_READS_PER_SESSION resource limit.
LOGICAL_READS_PER_SESSION
The query displayed below may be used to gather information about the LOGICAL_READS_PER_SESSION resource:
SELECT
SUBSTR(USERNAME,1,11) USERNAME
,AVG(LOGOFF_LREAD) AVG_LOGICAL_READS ,MAX(LOGOFF_LREAD) MAX_LOGICAL_READS ,COUNT(LOGOFF_LREAD) NUMBER_OF_LOGINS
FROM DBA_AUDIT_SESSION
GROUP BY USERNAME
/
Example Results:
CPU_PER_CALL
Aside from querying the Audit Trail, we may gather resource usage information from the V$ tables. The query displayed below may be used to gather information about the CPU_PER_CALL resource:
SELECT
SUBSTR(S.USERNAME,1,9) USERNAME ,SUBSTR(P.PROGRAM,1,18) PROGRAM ,SUBSTR(N.NAME,1,22) STATNAME ,ST.VALUE CALL_CPU
FROM V$SESSTAT ST,V$STATNAME N, V$SESSION S, V$PROCESS P
WHERE ST.STATISTIC# = N.STATISTIC# AND S.SID = ST.SID AND S.PADDR = P.ADDR
AND UPPER(N.NAME) LIKE '%CPU%CALL%'
ORDER BY S.USERNAME, N.NAME
/
Example Results:
USERNAME PROGRAM STATNAME CALL_CPU
--------- ------------------ ---------------------- ---------- OPS$DAN oracle_at_ava2 (Pipe CPU used when call sta 0 SCOTT oracle_at_ava2 (Pipe CPU used when call sta 0 OPS$O7 oracle_at_ava2 (TNS i CPU used when call sta 0 oracle_at_ava2 (PMON) CPU used when call sta 0 oracle_at_ava2 (DBWR) CPU used when call sta 0 oracle_at_ava2 (LGWR) CPU used when call sta 0 oracle_at_ava2 (SMON) CPU used when call sta 0 oracle_at_ava2 (RECO) CPU used when call sta 0
CPU_PER_SESSION
The query displayed below may be used to gather information about the CPU_PER_SESSION resource:
SELECT
SUBSTR(S.USERNAME,1,9) USERNAME
,SUBSTR(P.PROGRAM,1,18) PROGRAM ,SUBSTR(N.NAME,1,22) STATNAME ,ST.VALUE SESSION_CPU
FROM V$SESSTAT ST,V$STATNAME N, V$SESSION S, V$PROCESS P
WHERE ST.STATISTIC# = N.STATISTIC# AND S.SID = ST.SID AND S.PADDR = P.ADDR
AND UPPER(N.NAME) LIKE '%CPU%SESSION%'
ORDER BY S.USERNAME, N.NAME
/
Example Results:
IDLE_TIME
The query displayed below may be used to gather information about the IDLE_TIME resource:
SELECT
SUBSTR(S.USERNAME,1,9) USERNAME
,SUBSTR(P.PROGRAM,1,18) PROGRAM ,SUBSTR(N.NAME,1,22) STATNAME ,ST.VALUE IDLE_INFO
FROM V$SESSTAT ST,V$STATNAME N, V$SESSION S, V$PROCESS P
WHERE ST.STATISTIC# = N.STATISTIC# AND S.SID = ST.SID AND S.PADDR = P.ADDR
AND UPPER(N.NAME) LIKE '%IDLE%'
ORDER BY S.USERNAME, N.NAME
/
Example Results:
USERNAME PROGRAM STATNAME IDLE_INFO
--------- ------------------ ---------------------- ---------- OPS$DAN oracle_at_ava2 (TNS i process last non-idle 0 SCOTT oracle_at_ava2 (TNS i process last non-idle 0 OPS$O7 oracle_at_ava2 (TNS i process last non-idle 0 oracle_at_ava2 (PMON) process last non-idle 0 oracle_at_ava2 (DBWR) process last non-idle 0 oracle_at_ava2 (LGWR) process last non-idle 0 oracle_at_ava2 (RECO) process last non-idle 0 oracle_at_ava2 (SMON) process last non-idle 0
PRIVATE_SGA
Gathering statistics on the PRIVATE_SGA resource is not apparent to the author. Gathering statistics on the PGA, however, is easy. With knowledge about each user's PGA statistics, the DBA might make a reasonable guess about what are good values for the PRIVATE_SGA resource.
The query displayed below may be used to gather information about the PGA:
SELECT
SUBSTR(S.USERNAME,1,9) USERNAME
,SUBSTR(P.PROGRAM,1,18) PROGRAM ,SUBSTR(N.NAME,1,22) STATNAME ,ST.VALUE MEM_INFO
FROM V$SESSTAT ST,V$STATNAME N, V$SESSION S, V$PROCESS P
WHERE ST.STATISTIC# = N.STATISTIC# AND S.SID = ST.SID AND S.PADDR = P.ADDR
AND UPPER(N.NAME) LIKE '%MEM%'
AND S.USERNAME IS NOT NULL
ORDER BY S.USERNAME, N.NAME
/
Example Results:
USERNAME PROGRAM STATNAME MEM_INFO
--------- ------------------ ---------------------- ---------- OPS$DAN oracle_at_ava2 (TNS i max session memory 202620 OPS$DAN oracle_at_ava2 (TNS i session max pga memory 446500 OPS$DAN oracle_at_ava2 (TNS i session memory 164460 OPS$DAN oracle_at_ava2 (TNS i session pga memory 435996 OPS$DAN oracle_at_ava2 (TNS i sorts (memory) 0
SESSIONS_PER_USER
The query displayed below may be used to gather information about the number of sessions each user is running at this instant:
SELECT USERNAME, COUNT(USERNAME)
FROM V$SESSION
WHERE USERNAME IS NOT NULL
GROUP BY USERNAME
/
Example Results:
USERNAME COUNT(USERNAME)
------------------------------ --------------- OPS$DAN 2 OPS$O7 3 OPS$ROOT 1 SCOTT 5
Creating a History of the V$ Tables
Unlike the Audit Trail, the V$ tables provide only instantaneous data; we need to sample them periodically if we are to gain an accurate picture of resource usage by the dbs users. Once many samples are analyzed, we may then guess at appropriate resource limits for the dbs users. The shell script named v_sampler.sh has been included with this document and is intended to be run from cron. Each time cron runs it, a sample of some V$ data is saved to a set of history tables.
Managing the COMPOSITE_LIMIT Resource Limit
One of the Resource Limits is named the COMPOSITE_LIMIT. It limits users from using too much of a composite of Resource Limits. The COMPOSITE_LIMIT is made up of the following Resource Limits:
LOGICAL_READS_PER_SESSION CPU_PER_SESSION PRIVATE_SGA CONNECT_TIME
Perhaps a good name for the above four Resource Limits would be the "Valuable Limits".
ALTER RESOURCE COST
LOGICAL_READS_PER_SESSION 10 CPU_PER_SESSION 1 PRIVATE_SGA 5 CONNECT_TIME 1
/
Bob Decides on His COMPOSITE_LIMIT
After querying the Audit Trail and V$ Tables for resource usage, Bob has picked values for the Resource Limits of a specific profile:
CREATE PROFILE PR_BOB LIMIT
CONNECT_TIME UNLIMITED LOGICAL_READS_PER_CALL 12345 LOGICAL_READS_PER_SESSION 123450 CPU_PER_CALL 12345600 CPU_PER_SESSION 12345600 IDLE_TIME 120 PRIVATE_SGA 20M SESSIONS_PER_USER 5
/
Then, Bob applies a little arithmetic to the values of the Resource Limits in the PR_BOB profile:
sum_r_l = (LOGICAL_READS_PER_SESSION + CPU_PER_SESSION
+ PRIVATE_SGA + CONNECT_TIME)
sum_r_l = 33440570
As a final step in this scenario, Bob issues some sql statements to implement his wishes:
ALTER PROFILE PR_BOB LIMIT
COMPOSITE_LIMIT 33440570
/
ALTER RESOURCE COST
LOGICAL_READS_PER_SESSION 100 CPU_PER_SESSION 1 PRIVATE_SGA 1 CONNECT_TIME 0
/
ALTER USER BUFORD
PROFILE PR_BOB
/
Received on Mon Sep 20 1993 - 08:10:44 CEST