Oracle finds the table to be indexed

Source: Internet
Author: User

This article discusses the situations where the index should have been established due to negligence or Incomplete consideration.

Select distinct sp. OBJECT_NAME, round (ds. bytes/1024/1024, 2) MB, num_rows, last_analyzed
From v $ SQL _plan sp, v $ sqlarea sq, dba_segments ds, dba_tables dt
Where sq. ADDRESS = sp. ADDRESS
And ds. segment_name = sp. object_name
And dt. table_name = ds. segment_name
And sp. options = 'full'
And dt. owner = 'username'
And round (ds. bytes/1024/1024, 2)> 1
Order by round (ds. bytes/1024/1024, 2 );

The preceding SQL statement is as follows:
Locate the user and find the table with full table scan in v $ SQL _plan.
You can also use other visual charts (dba_tables, dba_segments) to list details of dba_tables: size, number of rows, and analysis time.
We can add another column. sq. SQL _text prints the SQL statement.
A condition is added that the table size is greater than 1 MB. Generally, the size of a 1 MB table is about 10 thousand rows. (If the number of rows in a 1 M Table is small, the high waterline may need to be recycled)
According to tests, the company's production database has approximately 25 MB of operate_detail data,
The data of the first row in the account_operate_detail table is about 10 thousand MB.
We will not consider small tables, because full table scan may be faster.
This SQL query result is for reference only. The specific problem must be analyzed in detail.
Of course, this is a final method. We should consider it when developing and designing, and use indexes for those columns, instead of performance problems.

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.