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.