It is generally believed that the indexes used by oracle databases will not exceed 25% of the total number of indexes created at design time, or they will not be used as expected. in practical applications, when the optimization speed is slow, it is often found that the executed SQL calls the junk index instead of the index we set up during design. therefore, it is necessary to monitor the database
It is generally believed that the indexes used by oracle databases will not exceed 25% of the total number of indexes created at design time, or they will not be used as expected. in practical applications, when the optimization speed is slow, it is often found that the executed SQL calls the junk index instead of the index we set up during design. therefore, it is necessary to monitor the database
General opinion:OracleThe index used by the database does not exceed the total number of indexes created at design.25%,Or they are not used as expected.In practical application,Query with slow tuning speed,It is often found that the executedSQLJunk index called,Instead of the index we created at design..Therefore, it is necessary to monitor the use of database indexes.,Release unused Indexes,This saves the cost of maintaining indexes.,Optimized Performance.
To check whether indexes in the current system are valid,From2008.09.19Index Monitoring,So far, we have tracked a total4Daily running data.Based on the index monitoring information,Analysis in several aspectsBiValidity of the system's background database index,And memory for maintaining invalid Indexes, IoAnd time expense.
1,Index validity statistics
First, create a temporary table to store the index used during the monitoring period.Ods. jax_t2 .,
CREATE TABLEOds. jax_t2 (
OwnerVARCHAR2(100),
Index_nameVARCHAR2(100),
Table_nameVARCHAR2(100),
MONITORING VARCHAR2(10),
UsedVARCHAR2(10)
)TABLESPACEOdsd;
Then use different accounts to log in,And execute the following statement,Write user information in a unified mannerOds. jax_t2Medium.
INSERT INTOOds. jax_t2 (owner, index_name, table_name,Monitoring, Used)
SELECT USER, Index_name, table_name,MONITORING, UsedFROMV $ OBJECT_USAGE;
COMMIT;
Finally, query the tableOds. jax_t2You can get the index effective usage..
SELECTOwner,COUNT(INDEX_NAME ),
NVL (SUM(DECODE (USED,'Yes',1,0)),0) Number of valid indexes,
ROUND (100* NVL (SUM(DECODE (USED,'Yes',1,0)),0)/
COUNT(INDEX_NAME ),
2) Index Efficiency
FROMOds. jax_t2
GROUP BYOwner
ORDER BYIndex efficiency;
|
Owner |
Total number of Indexes |
Number of valid Indexes |
Effective index rate(%) |
|
DC |
130 |
0 |
0 |
|
OD |
31 |
0 |
0 |
|
PRICE |
6 |
0 |
0 |
|
DP22 |
70 |
11 |
15.71 |
|
WAREHOUSE |
91 |
19 |
20.88 |
|
TODS |
224 |
48 |
21.43 |
|
FBI |
89 |
26 |
29.21 |
|
ODS |
355 |
105 |
29.58 |
|
DP23 |
70 |
28 |
40 |
|
DW |
50 |
23 |
46 |
|
RPT |
13 |
6 |
46.15 |
|
CTL |
32 |
20 |
62.5 |
|
Total |
1161 |
286 |
24.63 |
2,Index space usage statistics
Data DictionaryDba_segmentsStorage space allocation of database objects.We establishDba_segmentsAndOds. jax_t2You can query to obtain the total space allocation and valid indexes of each user.,Space occupied by Invalid Indexes.From the statistics, we can see that,In the total61GIndexing,Only11GEffective use of left and right Indexes.Other index spaces are not used during monitoring.,That is to say,This50 GBOnly maintenance overhead is required for indexes.,However, it fails to provide the function we imagined to increase the query speed..
SELECTDS. OWNER, SEGMENT_TYPE, ROUND (SUM(BYTES )/1024/1024),
Round (SUM(Decode (jt. used,'Yes', Ds. bytes,0))/1024/1024) Valid index,
Round (SUM(Decode (jt. used,'No', Ds. bytes,0))/1024/1024) Invalid Index
FROMDBA_SEGMENTS DS, ods. jax_t2 jt
WHEREDs. owner = jt. ownerANDDs. segment_name = jt. Index_Name
ANDDS. OWNERNOT IN('Sys','System','Outln','Wmsys')
ANDDS. SEGMENT_TYPE ='Index'
GROUP BYDS. OWNER, DS. SEGMENT_TYPE
ORDER BYInvalid Index
|
Owner |
Object Type |
Total index space(M) |
Valid index space(M) |
Invalid index space(M) |
|
DP23 |
INDEX |
5 |
2 |
3 |
|
DP22 |
INDEX |
4 |
1 |
4 |
|
OD |
INDEX |
7 |
0 |
7 |
|
RPT |
INDEX |
10 |
1 |
9 |
|
CTL |
INDEX |
34 |
22 |
13 |
|
FBI |
INDEX |
199 |
2 |
197 |
|
PRICE |
INDEX |
200 |
0 |
200 |
|
TODS |
INDEX |
1504 |
270 |
1235 |
|
DC |
INDEX |
2188 |
0 |
2188 |
|
DW |
INDEX |
5212 |
2325 |
2887 |
|
ODS |
INDEX |
22240 |
8703 |
13537 |
|
WAREHOUSE |
INDEX |
29750 |
4 |
29745 |
|
Total |
Index |
61353 |
11330 |
50023 |
3,Space and time spent on maintenance of Some Indexes
Here,I selected two tables for the relative execution time tutorial during data extraction.CR_CUSTOMER_EXPIATION_AAs CCEAAndCR_ORDER_ROLE as CORTable Analysis.
|
|
CCEA |
COR |
|
Space occupied by records |
28(M) |
2112(M) |
|
Space occupied by Indexes |
40(M) |
5072(M) |
|
Number of daily maintenance recordsDelete/Insert |
550138/550952 |
258593/279324 |
|
Invalid index count/Total number of Indexes |
1/1 |
2/4 |
|
Time required for deletion |
50.20(S) |
172(S) |
|
Time required for insertion |
16.25(S) |
39.22(S) |
|
Delete time after removing invalid Index |
19.88(S) |
23.77(S) |
|
The time required for insertion after removing invalid Indexes |
2.78(S) |
13.75(S) |
Based on the comparison above, we can see that,The total data size occupied by indexes in the system is as high60 GBAbove,However, the actual valid index space is only10GLeft and right,The vast majority of indexes only increase our maintenance time and space overhead.,But cannot provide support for system performance,Test data display,After deleting an invalid index,The system maintenance speed has been greatly improved.So I suggest:
1,Frequently searched tables,Find the query statement that references the table in the system,View its execution plan,Whether to use the correct index;
2,If you have used the correct index,You can use indexes and other methods to check whether the query speed can be improved.;
3,If the index does not increase the data retrieval speed,Then clear it.