The effect of Oracle Clustering factor on query performance

Source: Internet
Author: User
Tags create index sorts

CREATE TABLE T0

(

Sid int NOT NULL,

Sname VARCHAR2 (20)

)

Tablespace test;

--Loop Import data

Declare

MAXRECORDS constant int:=100000;

I int: = 1;

Begin

For I in 1..maxrecords loop

Insert into t0 values (i, ' Ocpyang ' | | i);

End Loop;

Dbms_output.put_line (' Successful data entry! ');

Commit

End

/

CREATE TABLE T1

As

Select Sid,sname from t0 to sname desc;

CREATE index index_t1 on T1 (SID);

CREATE TABLE T2

As

Select Sid,sname from T0 order by SID ASC;

Create index index_t2 on T2 (SID ASC);

--Analysis of two tables and their indices

EXEC dbms_stats.gather_table_stats (USER, ' T1 ');

EXEC dbms_stats.gather_table_stats (USER, ' T2 ');

EXEC dbms_stats.gather_index_stats (USER, ' index_t1 ');

EXEC dbms_stats.gather_index_stats (USER, ' index_t2 ');

---Compare the same query

Set Autot traceonly stat;

SELECT * from t1 WHERE Sid BETWEEN 120;

Statistical information

----------------------------------------------------------

5 Recursive calls

4 db block gets

Consistent gets consistent read

0 physical Reads

540 Redo Size

1240 Bytes sent via sql*net to client

530 bytes received via sql*net from client

3 sql*net roundtrips To/from Client

0 Sorts (memory)

0 Sorts (disk)

Processed rows

SELECT * from T2 WHERE SID BETWEEN 120;

Statistical information

----------------------------------------------------------

6 Recursive calls

4 db block gets

9 consistent gets consistent read

0 physical Reads

540 Redo Size

1240 Bytes sent via sql*net to client

530 bytes received via sql*net from client

3 sql*net roundtrips To/from Client

0 Sorts (memory)

0 Sorts (disk)

Processed rows

Set Autotrace off;

Related Article

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.