Introduction to Oracle Hints

Source: Internet
Author: User
Tags count create index hash sorts

Hints translated into Chinese is the hint, implied meaning, it is in the database role is to change the execution of SQL statements, you can use hints to force SQL in the way you set up to execute SQL, generally used to do performance diagnostics and tuning, not recommended in development.

1. Write a SQL, so that it through the full table scanning mode of efficiency better than the index access, respectively, give their own implementation plan.

Leo1@leo1> CREATE TABLE Leo1 as SELECT * from Dba_objects; Create a Leo1 table

Table created.

Leo1@leo1> CREATE index Idx_leo1 on leo1 (object_id); Create an index on this object_id column

Index created.

Leo1@leo1> Execute dbms_stats.gather_table_stats (' LEO1 ', ' LEO1 ', cascade=>true); Analysis Tables and indexes

Pl/sql procedure successfully completed.

Leo1@leo1> Select COUNT (*) from LEO1; There are 71958 lines of records on the table

COUNT (*)

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

71958

Leo1@leo1> Select/*+ Full (LEO1)/* from Leo1 where object_id>100;

71859 rows selected.

Execution Plan

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

Plan Hash value:2716644435

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

| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |

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

| 0 |      SELECT STATEMENT | |  71862 |   6807k| 287 (1) | 00:00:04 |

|* 1 | TABLE ACCESS full| LEO1 |  71862 |  6807k| 287 (1) | 00:00:04 |

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

predicate information (identified by Operation ID):

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

1-filter ("object_id" >100)

Statistics

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

1 Recursive calls

0 db Block gets

5762 consistent gets 5,762-time consistency reading

0 physical Reads

0 Redo Size

3715777 Bytes sent via sql*net to client

53214 bytes received via sql*net from client

4792 sql*net roundtrips To/from Client

0 Sorts (memory)

0 Sorts (disk)

71859 rows processed

Leo1@leo1> Select/*+ Index (leo1 idx_leo1) * from Leo1 where object_id>100;

71859 rows selected.

Execution Plan

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

Plan Hash value:1434365503

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

| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |

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

| 0 |          SELECT STATEMENT | |  71862 |  6807k| 1232 (1) | 00:00:15 |

|  1 | TABLE ACCESS by INDEX rowid| LEO1 |  71862 |  6807k| 1232 (1) | 00:00:15 |

|* 2 | INDEX RANGE SCAN | Idx_leo1 |       71862 |  | 160 (0) | 00:00:02 |

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

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.