You are on page 1of 7
Ac Wedt|unws samsine comyso Get 2months of ad-free YouTube Automatic Indexing (DBMS_AUTO_INDEX) in Oracle anne oa Database 19c sannsonng Sate Cnc database 19 lntoduced Ue sutomsticndening fetue, which ets you hind over some ofthe decione about index management othe database 0} “+ What 000% + Pretequisites + Configuration © Display Configuration © Enable/Diable Automatic Indexing © Inblespace for Automatic Indexes © Schema-Level Contra © Other Configuration ‘+ rop Secondary indexes = Views «Activity Report What It Does The automatic indexing feature does te following ‘+ Ldentty potential automatic indexes based on the table column usage. The documentation calls these "eandate indexes” ‘Create automatic indexes a invisible indexes, so they are not used in execution plans. Index names include the "S¥S.AI" prec «Test the invisible automatic indexes against SQL statements to make sure they give improved performance. If they result in improved performance they are made visible. performance is not improved, the relevant automatic index is marked 9s unusable and later removed, The SQL statements tested against file automatic indexes are black sted, $0 they will not be considered for automatic Indexing in future, Automatic indexes are not considered by the optimizer for Fst time SQL. run agains the database, ++ Delete unused indexes, Ive never used ths feature on an Exadata,s0 fm notin a positon to comment on its effectiveness, ites Prerequi: This feature is curently rest trprise Ee the“ exadata_feature_on” initialisation parameter, icted 106 tion on Enginesred Systems, as described here, There isa workaround for testing by enabling export ORACLE_StD-c301 export OMAENY_ASK=NO export ORAENY_ASK=YES saiplus / a sysdbo «EOF alter system sot “_exadta_festure_on"strue scopesspfiles Sshuteown imeciate; This ie not supported and shoukin' be used on 3 real system. Configuration ‘The oons_su1o_tex package is used to manage the automatic indexing feature. The basic managements described below. Display Configuration The coR_Aure_sHDEX_cONFIG view displays the current automatic indexing configuration. The following querys available asthe auto index, config sl script COUN paraneter_pane FORMAT MO (COLUM paraneter_value FORT AIS SELECT con_44, parameter nate, parameter value ORDER BY, 2 OMLTO PARAMETER NE PAnAneER_UALUE 1 AUTO_ZNDEX_ RETENTION FOR MANA 2 AUTO_ZNDEXC RETENTION FOR_MANAL seo Fie switch toa user-defined pluggable database, we only get the values fo that container, SQL> favto_incox_contie.sal 21 AUTO_INDEX REPORT RETENTION a 2 ONDE RETENTICN_FOR AUTO on sa The parameters are explained in detail here. Enable/Disable Automatic Indexing ‘Automatic indexing is configured using the cour1cune procedure ofthe DaMs_auro_Ex package, ‘The on-off switeh for automatic indexing is controlled using the auto_190EX MODE propery, which has the following allowed values, “+ pLenent: Tums on automatic indexing, New indexes that improve performance are made visible and available for use by the optimizer, ‘+ epoar OnLy: Turns on automatic indexing but new indexes remain invisible «OFF Turns off automatic indexing Examples of switching between modes are shown below. {EXEC ONS_AUTO_INDEX. CONFZGURE( “AUTO. INDEX MODE”, IHPLINENT): {XE O4S_AUTO_ INDEX. CONFIGURE (AUTO INDEX MODE”, "PORT ONLY"); EC D945 TO“ INDEX. CONFIGURE (AUTO INDEX WOE”, OFF"); Tablespace for Automatic Indexes By default automatic indexes are created inthe default permanent tablespace. ths isnot acceptable, you can specif a tablespace to hold ‘them using the AUTO_THOEXDErAULT_TABLESPACE property. Below We creat 2 tablespace to hold the automatic indexes, and set the propery accordingly on [ALTER SESSION SET CONTAINER = pbs {EC OONS_AUTO_INDEX. CONFLGURE(*ALTO_INGEX_DEFAULT_TABLESPACE®, "AUTO_INDEXES_1S"); Set to NULL to return to using the default permanent tablespace EC OBMS_AUTO_INDEX. CONFIGURE( ‘AUTO, NOEX_DEFAULT_TABLESPACE MULL); ‘Schema-Level Control ‘once automatic indexing is enabled, al schemas are considered when trying to identity candidate indexes. ou can alter the default behaviour Using the avTe_INDEX_ScileNA property, which allows yau to maintain an inelusiorVexclusion ls. the aLLou parameters set to TRUE the spectied schema i add tothe inclusion lst. Notice it builds a predicate containing the schemas. EXEC OBMS_AUTO_INDEX.CONFIGURE(‘AUTO_INOEX SCHEMA’, “TEST, allow => TRUE); EXEC O5MS_AUTO_INDEX.CONFTGURE(‘AUTO_ INDEX SCHEMA’, “TEST2", allow => TRUE); SQL> feuto_inden_contig.sql COWL TO PARAMETER NAME PAwanerER VALUE 2) auro_3NooX SCHEMA sehera IN (TEST, TEST2) 2: yTo_NDeXSace_puoceT se sev The inclusion ist can be blanked using the NULL parameter value EC ONS_AUTO_INDEX.CONFIGURE( “AUTO IOEX SOHENA', HULL, atTow rue); SQL> fauto_Sndox_config.sq1 OIL TO PARMRETERL NE 2 AUTO_ZNDEX_ RETENTION FORMAL 3 auTe_3NoeX SCHEMA se I the aLtou parameter is st to FALSE, the specified schemas are added tothe exclusion lit air EXEC OBNS_AUTO_INDEX. CONFIGURE(‘AUTO_INDEX_SOHEMA', “TEST, allow => FALSE); [EXEC ONS_AUTO_INDEX.CONFIGURE(‘AUTO INDEX ScHEMA', “TEST2", allow => FaLSt); SQL> faute_snden contig. OLD PARAMETER NAME PAWAneER VALUE 2 aura Nex SCHEMA schora NOT IN (TEST, TEST2) 2: To“. Sace_buogeT se sav ‘The exclusion lst canbe blanked using the NULL parameter value {XE ONS_AUTO_INDEX.CONFIGURE(‘AUTO_INDEX SONOMA’, MULL, alow => FALSE): SQL> fouto_Sndox_contig.sg2 OL PARAMETER NE Panne 2 AUTO_ANDEX_ RETENTION FOR MANA 3 auTo_3NOeX SCHEMA soe Other Configuration ‘There are other parameters you may wish to consider, which ae all explained in detail hea ‘+ suro_p1o0x_coveRessr0N: Undocumented. Presumably use to contol the level of compression. Default "OFF “+ auro_ZNDEX_REPORT_RETENTZON: Retention petiod for automatic indexing logs. Reporting is based on these log. Default 21 days ‘+ Auro_2100X RETENTION, FOt_AUTO = Retention period for unused automatic indexes. Default 373 days ‘+ nuTo_p106x RETENTION. FOR faNuAL: Retention period for unused manually created indexes. When set to NULL, manually created indexes sre not considered for removal, Default NULL ‘+ nuTo_1000X_sPace_Qu06ET: Percentage ofthe default permanent tablespace used to automatic index storage. This parameters ignored when using the AUTO. INDEX DEFAULT_TABLESPACE parameter to specify a custom tablespace, Drop Secondary Indexes Think vary carefully before doing this, and test test test! you are feeling particularly brave, the okoe_sFconDARy_z2eXES procedure will drop llindexes except those used for constraints. This can be done at table, schema or database level {XE ONS_AUTO_INOEX.drop_secondary_sndexes(*HY_SCHERA, "MY_TABLE'); EC BNS_AUTO_INDEX.drop_secondary_sndexos("HY_SCHEHA')3 <= ontabase- evel EXEC OBN5_AUTO_INDEX.dop_secondary indexes This leaves you with a clean sate, so automatic indexing can make all your indexing decisions for you a Views ‘There are several views associated with the automatic indexing featur, a6 shown below: Only the fist is documented inthe reference manual at the time of writing, onoeR By 13 — ‘BB4_AUTO_INDEX_SQL_ACTIONS (084_AUTO_INDEX VERIFICATIONS sav In adltion, the (eo8]bea|ALL USER) _t6ExES Views include the aura column, which indicates if an index was created by the automatic indexing feature. The folowing query s valable asthe auta indexes cl script COLUM table owner FORMAT 138 FROM dba_indexes ORDER BY camer, Sndex.none: Activity Reports The omts_auro_swo8x package contains two reporting functions MS_AUTO_INDEX.REPORT_ACTEVETY ( setivity.start IN TIRESTAYD WITH TIRE 20NE DEFAULT SYSTINESTARD = 2, setivitylerd IN TIRESTHWD WITH TIME ZONE OEFRILT SYSTIRESTARD, ‘ye 1m vanciana DEFAULT "TEXT", level 1K. VARCHAR DEFAULT “TYPICAL! WMS_AUTO_INDEX.REPORT_LAST_ACTIVETY ( ye 1m vaaciaaa eFAuLT “TEXT, section TW vaachana DEFAULT “ALL, revel TN VARCHAR DEFAULT "TYPICAL" ‘The RevoRt_AcTEVITY function allows you to ispay activity ever a specfed period of time, which defaults to the last day. The RevoRt\AST_ACTIVITY function reports the [st automatic indexing operation, Both allow you to tailor the output using the following parameters ‘+ 79Pe Allowable values TEXT, HTML, XML), “+ cT10N: Allowable values (SUMMARY, INDEX.DETAILS, VERIFICATION. DETAILS, ERRORS, ALL) You can also use combinations withthe and" characters to indicate if something should be included or excluded, For example SUMMARY ERRORS’ or ‘ALL ERRORS" “= LEVEL Alowable values BASIC, TYPICAL, ALL Some examples of using these function from SQL are shown below, Notice the quoting ofthe LEVEL parameter. Ths is necessary when using thsi a SQL call so ie understands this isn't a reference to the LeveL pseudo-column, on + oefault TEXT report for the Last 26 hours. SELECT DBS _aUTO_INDEXreport_activity() FROY dual; + oefault TEXT report for the Latest activity SELECT 0605 _AUTO_INDEX.repors_last_activity() FROM duals <= HIM. Report for the day before yesterday SELECT 6NS_AUTO_IWOEX.report_actsvityt achivity_start => SVSTIHESTANP-2, detivity_end => SYSTINESTANP-2, te me) = Am. report for the Latest activity SELECT 065 _AUTO_INOEX.report_last_activity( ‘ype => HTML) FROM wal; = Wh. Report for the day before yesterday with all inform SELECT DBHS_AUTO_ENDEX.regort_activity( sctiviey_start => SVSTINESTAN-2, aetivigylend o> SYSTINESTANP-2, ‘ype section FAN dal: <= Wi. report for the latest activity with sll infornation, SELECT 0685 _AUTO_INDEL report Tast_aetivity( ype => HIM, section > “ALL, Level” > ALLY) FROM als Here is an example ofthe output from the defeuk activity report before any indexes have been crested. er SELECT 065 _AUTO_INDEX.report_activity() FROW dual; etivity end executions completed Execotions interrupted Executions with fatal error suwuay (auto INDEXES) Indexes created space used ncexes dropped SQL statenents verktiee SQL statenente improve SOL plan naselines created Overall inprovenent factor SUNY (HARINL SHOERES) Unused indewes 1 @ space used oe Unusable indexes: @ fsesunere9 24:59:21, No errors found sep ‘+ Managing Aut Indexes ‘+ DAMS AUTO INDEX ope this helps, Regards Tim ackto the Top. ‘comments tead/add them, ‘Home| Articles | Sriots | log | Cetfcation | Videos| Misc | About About Ti Hal Copyright 8 Diselaimer m

You might also like