ComparisonofIndexTypes
TeradataDatabasedoesnotrequireorallowuserstoexplicitlydictatehowindexesshouldbeusedforaparticularquery.
TheOptimizercostsallofthereasonablealternativesandselectstheonethatisestimatedtobetheleastexpensive.
Theobjectofanyqueryplanistoreturnaccurateresultsasquicklyaspossible.Therefore,theOptimizerusesanindexor
indexesonlyiftheindexspeedsupqueryprocessing.Insomecases,theOptimizerprocessesthequerywithoutusingany
index.
Optimizerindexselectionforaqueryplan:
CanhaveadirectimpactonoverallTeradataDatabaseperformance.
Isnotalwaysastraightforwardprocess.
Isbasedpartlyonusageexpectations.
ThefollowingtableassumesexecutionofasimpleSELECTstatementandexplainsthestrengthsandweaknessesofsome
ofthevariousindexingmethods.
Andthefollowingpossible
drawbacks
Thisaccessmethod
Hasthefollowingstrengths
UniquePrimaryIndex(UPI)
isthemostefficientaccessmethod
whentheSQLstatementcontainsthePI
value
involvesoneAMPandonerow
requiresnospoolfile(forasimple
SELECT)
canobtainthemostgranularlocks
providesefficientaccesswhentheSQL
statementcontainsthePIvalue
mayslowdownINSERTsforaSET
tablewithnoUSIs.
involvesoneAMP
canobtaingranularlocks
maynotrequireaspoolfileaslongas
thenumberofrowsreturnedissmall
maydecreasetheefficiencyof
SELECTscontainingthePIvaluewhen
somevaluesarerepeatedinmany
rows.
providesefficientaccesswhentheSQL
statementcontainstheUSIvalues,and
youdonotspecifyPIvalues
involvestwoAMPsandonerow
requiresnospoolfile(forasimple
SELECT)
providesefficientaccesswhenthe
numberofrowspervalueinthetableis
relativelysmall
requiresadditionaloverheadfor
INSERT,UPDATE,MERGE,and
DELETEstatements.
involvesallAMPSandprobablymultiple
rows
providesaccessusinginformationthat
maybemorereadilyavailablethana
willnotbeusedbytheOptimizerifthe
numberofdatablocksaccessedisa
significantpercentageofthedatablocks
inthetablebecausetheOptimizerwill
determinethatafulltablescanis
NonuniquePrimaryIndex(NUPI)
UniqueSecondaryIndex(USI)
NonuniqueSecondaryIndex(NUSI)
none,inthecontextofaSELECTstatement
specifyingaPIvalue.However,apoorly
chosenPIcancausepooroverall
performanceinalargeworkload.
requiresadditionaloverheadforINSERT,
UPDATE,MERGE,andDELETE
statements.
UPIvalue,suchasemployeelastname,
comparedtoanemployeenumber
Fulltablescan
Multitablejoinindex(JI)
Singletablejoinindex(JI)
mayrequireaspoolfile
accesseseachrowonlyonce
examineseveryrow.
providesaccessusinganyarbitraryset
ofcolumnconditions
usuallyrequiresaspoolfilepossiblyas
largeasthebasetable.
caneliminatetheneedtoperform
certainjoinsandaggregatesrepetitively
maybeabletosatisfyaquerywithout
referencingthebasetables
requiresadditionaloverheadfor
INSERT,UPDATE,MERGE,and
DELETEstatementsforanyofthebase
tablesthatcontributetothemultitableJI.
canhaveadifferentPIfromthatofthe
basetable
canreplaceanNUSIoraUSI
usuallyisnotsuitablefordataintables
subjectedtoalargenumberofdaily
INSERT,UPDATE,MERGE,and
DELETEstatements.
imposessomerestrictionsonoperations
performedonthebasetable.
canisolatefrequentlyusedcolumns(or
theiraggregatesforJIsonly)fromthose
thatareseldomused
requiresadditionaloverheadfor
INSERT,UPDATE,MERGE,and
DELETEstatements.
canreducenumberofphysicalI/Os
whenonlycommonlyusedcolumnsare
referenced
imposessomerestrictionsonoperations
performedonthebasetable.
canhaveadifferentPIfromthatofthe
basetable
canbestoredinlessspacethanan
ordinaryJI
reducestheadditionaloverhead
associatedwithINSERT,UPDATE,
MERGE,andDELETEstatementsto
thebasetablewhencomparedwithan
ordinaryJI
requiresadditionaloverheadfor
INSERT,UPDATE,MERGE,and
DELETEstatementstothebasetable.
imposessomerestrictionsonoperations
performedonthebasetable.
or
hashindex
Sparsejoinindex(JI)
cheaper.
canexcludecommonvaluesthatoccur
inmanyrowstohelpensurethatthe
OptimizerchoosestousetheJIto
accesslesscommonvalues