|Oracle9i SQL Reference
Release 2 (9.2)
Part Number A96540-01
SQL Statements: ALTER CLUSTER to ALTER SEQUENCE, 18 of 21
COST statement to specify or change the formula by which Oracle calculates the total resource cost used in a session.
Although Oracle monitors the use of other resources, only the four resources shown in the syntax can contribute to the total resource cost for a session.
Once you have specified a formula for the total resource cost, you can limit this cost for a session with the
COMPOSITE_LIMIT parameter of the
PROFILE statement. If a session's cost exceeds the limit, Oracle aborts the session and returns an error. If you use the
COST statement to change the weight assigned to each resource, Oracle uses these new weights to calculate the total resource cost for all current and subsequent sessions.
CREATE PROFILE for information on all resources and on establishing resource limits
You must have
COST system privilege.
Specify the amount of CPU time that can be used by a session measured in hundredth of seconds.
Specify the elapsed time allowed for a session measured in minutes.
Specify the number of data blocks that can be read during a session, including blocks read from both memory and disk.
Specify the number of bytes of private space in the system global area (SGA) that can be used by a session. This limit applies only if you are using Shared Server architecture and allocating private space in the SGA for your session.
Specify the weight of each resource. The weight that you assign to each resource determines how much the use of that resource contributes to the total resource cost. If you do not assign a weight to a resource, the weight defaults to 0, and use of the resource subsequently does not contribute to the cost. The weights you assign apply to all subsequent sessions in the database.
Oracle calculates the total resource cost by first multiplying the amount of each resource used in the session by the resource's weight, and then summing the products for all four resources. For any session, this cost is limited by the value of the
COMPOSITE_LIMIT parameter in the user's profile. Both the products and the total cost are expressed in units called service units.
The following statement assigns weights to the resources
The weights establish this cost formula for a session:
where the values of
CONNECT_TIME are either values in the
DEFAULT profile or in the profile of the user of the session.
Because the preceding statement assigns no weight to the resources
PRIVATE_SGA, these resources do not appear in the formula.
If a user is assigned a profile with a
COMPOSITE_LIMIT value of 500, a session exceeds this limit whenever
cost exceeds 500. For example, a session using 0.04 seconds of CPU time and 101 minutes of elapsed time exceeds the limit. A session using 0.0301 seconds of CPU time and 200 minutes of elapsed time also exceeds the limit.
You can subsequently change the weights with another
These new weights establish a new cost formula:
where the values of
LOGICAL_READS_PER_SECOND are either the values in the
DEFAULT profile or in the profile of the user of this session.
COST statement changes the formula in these ways:
CPU_PER_SESSIONresource and the resource was already assigned a weight, so the resource remains in the formula with its original weight.
LOGICAL_READS_PER_SESSIONresource, so this resource now appears in the formula.
CONNECT_TIMEresource, so this resource no longer appears in the formula.
PRIVATE_SGAresource and the resource was not already assigned a weight, so the resource still does not appear in the formula.