Oracle object statistics

Source: Internet
Author: User

I. Overview

Object statistics describe how data is stored in the database. For example, how many rows of data exist in a table and the maximum value of a column. This information helps the query optimizer find the correct and efficient execution plan. For example, in a specific scenario, which traffic mode is the fastest? Cars, trains, or planes? If you don't know where I am and where I am, you won't get a reasonable answer. Similarly, if no object statistics are available, the query optimizer cannot find a correct and efficient execution plan.

2. Available object statistics

There are three types of object statistics available: Table statistics, column statistics, and index statistics. The following example shows the types of statistics provided by these three types.

1. Prepare table data

SET SERVEROUTPUT ON

Drop table t;

Execute dbms_random.seed (0)

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 dual
Connect by level <= 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;
/

The stored procedure is used to collect the statistics of the current user table T. The meaning of each parameter is not described.

  • 1
  • 2
  • 3
  • 4
  • Next Page

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.