UPDATE STATISTICS

Updates database statistics for query optimization.

SYNTAX

object_list List of database objects to update statistics data for.
number Percentage of data to use when updating statistics data.

DESCRIPTION

The UPDATE STATISTICS command updates database statistics information. Keeping statistics information current helps the database to perform queries more efficiently. To execute the UPDATE STATISTICS command, you must have DBA or SYSADM security privileges, or be the owner of the object you are updating statistics for.

You can update statistics information for the entire database, or you can take update statistics information for only one or more tables. For each table, you can specify whether you want to update the table statistics information, the column statistics information, the index statistics information, or a combination of the three. You can also specify the amount of data to sample as a percentage of the total by specifying a number between 1 and 100 for the SAMPLE keyword.

For table data, DBMaker records statistics on the number of pages, the number of rows, and the average row length of sampled rows in a table. For column data, DBMaker records statistics on the number of distinct column values, the average column length, the low value, and the high value for all sampled values in a column. For index data, DBMaker records statistics on the number of index pages, the number of index tree levels, the number of leaf pages, the number of distinct key values, the number of pages per key, and the cluster count for the index.

Object List

EXAMPLE

The following example updates all statistics information in the database with a sampling percentage of 30%.

UPDATE STATISTICS SAMPLE = 30

The following example updates all statistics on table1.

UPDATE STATISTICS table1 SAMPLE = 50

The following example updates statistics only for column c1 and index ix1 on table1.

UPDATE STATISTICS table1 (COLUMN (c1) index (ix1))

RELATED COMMANDS

< UPDATE | Contents >

Copyright 2002 SYSCOM Computer Engineering Co. All rights reserved.