Home > Database > Mysql Tutorial > body text

Oracle中收集表与列统计信息

WBOY
Release: 2016-06-07 17:33:46
Original
1246 people have browsed it

关于每一列的解释联机文档上都有,这里blocks是高水位以下的数据块数,empty_blocks是高水位以上的数据块数。Dbms_stats不计算EM

我们在分析某些语句的性能时,会分析一些信息。像表、列、索引、直方图等等,本篇主要讲表与列的统计信息收集与分析。

一、表统计信息

首先创建一个测试表,,更新一些数据,加入一些约束:

CREATE TABLE t
AS
SELECT rownum AS id,
      round(dbms_random.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 ROWNUMORDER BY dbms_random.value;

UPDATE T SET VAL1 = NULL WHERE VAL1

ALTER TABLE t ADD CONSTRAINT t_pk PRIMARY KEY(ID);

CREATE INDEX t_val1_i ON t(val1);
CREATE INDEX t_val2_i ON t(val2);

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

此时表已经搜集了统计信息,查看表的统计信息用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

 

关于每一列的解释联机文档上都有,这里blocks是高水位以下的数据块数,empty_blocks是高水位以上的数据块数。Dbms_stats不计算EMPTY_BLOCKS、AVG_SPACE、CHAIN_CNT。

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template