Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

ASSOCIATE STATISTICS

ASSOCIATE STATISTICS

Purpose

Use the ASSOCIATE STATISTICS statement to associate a statistics type (or default statistics) containing functions relevant to statistics collection, selectivity, or cost with one or more columns, standalone functions, packages, types, domain indexes, or indextypes.

For a listing of all current statistics type associations, query the USER_ ASSOCIATIONS data dictionary view. If you analyze the object with which you are associating statistics, then you can also query the associations in the USER_USTATS view.

See Also: ANALYZE on page 12-34 for information on the order of precedence with which ANALYZE uses associations

Prerequisites

To issue this statement, you must have the appropriate privileges to alter the base object (table, function, package, type, domain index, or indextype). In addition, unless you are associating only default statistics, you must have execute privilege on the statistics type. The statistics type must already have been defined.

See Also: CREATE TYPE on page 16-3 for information on defining types

Syntax

associate_statistics::=

 

 

 

column_association

ASSOCIATE

STATISTICS

WITH

;

 

 

 

function_association

column_association::=

,

schema .

COLUMNS

table

.

column

using_statistics_type

12-50 Oracle9i SQL Reference

ASSOCIATE STATISTICS

function_association::=

 

 

,

 

 

 

schema

.

 

 

 

FUNCTIONS

 

function

 

 

 

 

 

,

 

 

 

schema

 

.

 

 

 

PACKAGES

 

package

 

 

 

,

 

 

using_statistics_type

 

 

 

 

 

 

 

schema

.

 

,

default_selectivity_clause

TYPES

 

type

 

default_cost_clause

 

 

 

 

 

 

 

 

,

 

 

,

default_cost_clause

 

 

 

 

schema

.

 

default_selectivity_clause

 

 

INDEXES

 

index

 

 

 

 

 

,

 

 

 

schema

.

 

 

 

INDEXTYPES

 

indextype

 

 

 

using_statistics_type::=

schema .

statistics_type

USING

NULL

default_cost_clause::=

DEFAULT COST ( cpu_cost , io_cost , network_cost )

default_selectivity_clause::=

DEFAULT SELECTIVITY default_selectivity

SQL Statements: ALTER TRIGGER to COMMIT 12-51

ASSOCIATE STATISTICS

Semantics

column_association

Specify one or more table columns. If you do not specify schema, then Oracle assumes the table is in your own schema.

function_association

Specify one or more standalone functions, packages, user-defined datatypes, domain indexes, or indextypes. If you do not specify schema, then Oracle assumes the object is in your own schema.

FUNCTIONS refers only to standalone functions, not to method types or to built-in functions.

TYPES refers only to user-defined types, not to built-in SQL datatypes.

Restriction on function_association You cannot specify an object for which you have already defined an association. You must first disassociate the statistics from this object.

See Also: DISASSOCIATE STATISTICS on page 16-64 "Associating Statistics: Example" on page 12-53

using_statistics_type

Specify the statistics type (or a synonym for the type) being associated with column, function, package, type, domain index, or indextype. The statistics_type must already have been created.

The NULL keyword is valid only when you are associating statistics with a column or an index. When you associate a statistics type with an object type, columns of that object type inherit the statistics type. Likewise, when you associate a statistics type with an indextype, index instances of the indextype inherit the statistics type.You can override this inheritance by associating a different statistics type for the column or index. Alternatively, if you do not want to associate any statistics type for the column or index, then you can specify NULL in the using_ statistics_type clause.

Restriction on Specifying Statistics Type You cannot specify NULL for functions, packages, types, or indextypes.

See Also: Oracle9i Data Cartridge Developer’s Guide for information on creating statistics collection functions

12-52 Oracle9i SQL Reference

ASSOCIATE STATISTICS

default_cost_clause

Specify default costs for standalone functions, packages, types, domain indexes, or indextypes. If you specify this clause, then you must include one number each for CPU cost, I/O cost, and network cost, in that order. Each cost is for a single execution of the function or method or for a single domain index access. Accepted values are integers of zero or greater.

default_selectivity_clause

Specify as a percent the default selectivity for predicates with standalone functions, types, packages, or user-defined operators. The default_selectivity must be a number between 0 and 100. Values outside this range are ignored.

Restriction on the default_selectivity_clause You cannot specify DEFAULT SELECTIVITY for domain indexes or indextypes.

See Also: "Specifying Default Cost: Example" on page 12-53

Examples

Associating Statistics: Example This statement creates an association for the standalone package emp_mgmt (created in "Creating a Package: Example" on page 14-55):

ASSOCIATE STATISTICS WITH PACKAGES emp_mgmt DEFAULT SELECTIVITY 10;

Specifying Default Cost: Example This statement specifies that using the domain index t_a to implement a given predicate always has a CPU cost of 100, I/O of 5, and network cost of 0.

ASSOCIATE STATISTICS WITH INDEXES t_a DEFAULT COST (100,5,0);

The optimizer will simply use these default costs instead of calling a cost function.

SQL Statements: ALTER TRIGGER to COMMIT 12-53

Соседние файлы в папке Oracle selected docs