Collect table and column statistics in Oracle

Source: Internet
Author: User
The explanations for each column are available in the online documentation. Here, blocks is the number of data blocks below the high water level, and empty_blocks is the number of data blocks above the high water level. Dbms_stats does not calculate EM

The explanations for each column are available in the online documentation. Here, blocks is the number of data blocks below the high water level, and empty_blocks is the number of data blocks above the high water level. Dbms_stats does not calculate EM

When analyzing the performance of some statements, we will analyze some information. Such as tables, columns, indexes, and histograms. This article mainly describes the collection and analysis of statistical information of tables and columns.

I. Table statistics

First, create a test table, update some data, and add some constraints:

Create table t
AS
SELECT rownum AS id,
Round (dbms_randm.normal * 1000) AS val1,
100 + round (ln (rownum/3.25 + 2) AS val2,
100 + round (ln (rownum/3.25 + 2) AS val3,
Dbms_random.string ('P', 250) AS pad
FROM All_Objects
Where rownum <= 1000
Order by dbms_random.value;

Update t set VAL1 = null where VAL1 <0;

Alter table t add constraint t_pk primary key (ID );

Create index t_valinii ON t (val1 );
Create index t_val2_ I ON t (val2 );

BEGIN
DBMS_STATS.GATHER_TABLE_STATS (OWNNAME => USER,
TABNAME => 'T ',
ESTIMATE_PERCENT = & gt; 100,
METHOD_OPT => 'for all columns size skewonly ',
CASCADE => TRUE );
END;

At this time, the table has collected statistics. To view the statistical information of the table, use user_tab_statistics.

SELECT NUM_ROWS, BLOCKS, EMPTY_BLOCKS, AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN
FROM USER_TAB_STATISTICS
WHERE TABLE_NAME = 'T ';

NUM_ROWS

BLOCKS

EMPTY_BLOCKS

AVG_SPACE

CHAIN_CNT

AVG_ROW_LEN

1000

44

0

0

0

265

The explanations for each column are available in the online documentation. Here, blocks is the number of data blocks below the high water level, and empty_blocks is the number of data blocks above the high water level. Dbms_stats does not calculate EMPTY_BLOCKS, AVG_SPACE, and CHAIN_CNT.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.