Heapsofdata:tableswithoutclusteredindexes

来源:互联网 发布:网络棋牌害死人 编辑:程序博客网 时间:2024/06/05 16:58
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

IfyoucreateatableonAdaptiveServer,butdonotcreateaclusteredindex,thetableisstoredasaheap.Thedatarowsarenotstoredinanyparticularorder.Thissectiondescribeshowselect,insert,delete,andupdateoperationsperformonheapswhenthereisno"useful"indextoaidinretrievingdata.

Thephrase"nousefulindex"isimportantindescribingtheoptimizer'sdecisiontoperformatablescan.Sometimes,anindexexistsonthecolumnsnamedinawhereclause,buttheoptimizerdeterminesthatitwouldbemorecostlytousetheindexthantoperformatablescan.

Otherchaptersinthisbookdescribehowtheoptimizercostsqueriesusingindexesandhowyoucangetmoreinformationaboutwhytheoptimizermakesthesechoices.

Tablescansarealwaysusedwhenyouselectallrowsinatable.Theonlyexceptioniswhenthequeryincludesonlycolumnsthatarekeysinanonclusteredindex.

Formoreinformation,see"Indexcovering".

ThefollowingsectionsdescribehowAdaptiveServerlocatesrowswhenatablehasnousefulindex.
Lockschemesanddifferencesbetweenheaps
Thedatapagesinanallpages-lockedtablearelinkedintoadoubly-linkedlistofpagesbypointersoneachpage.Pagesindata-only-lockedtablesarenotlinkedintoapagechain.

Inanallpages-lockedtable,eachpagestoresapointertothenextpageinthechainandtothepreviouspageinthechain.Whennewpagesneedtobeinserted,thepointersonthetwoadjacentpageschangetopointtothenewpage.WhenAdaptiveServerscansanallpages-lockedtable,itreadsthepagesinorder,followingthesepagepointers.

Pagesarealsodoubly-linkedateachindexlevelofallpages-lockedtables,andtheleaflevelofindexesondata-only-lockedtables.Ifanallpages-lockedtableispartitioned,thereisonepagechainforeachpartition.

Anotherdifferencebetweenallpages-lockedtablesanddata-only-lockedtablesisthatdata-only-lockedtablesusefixedrowIDs.ThismeansthatrowIDs(acombinationofthepagenumberandtherownumberonthepage)donotchangeinadata-only-lockedtableduringnormalqueryprocessing.

RowIDschangeonlywhenoneoftheoperationsthatrequiredata-rowcopyingisperformed,forexample,duringreorgrebuildorwhilecreatingaclusteredindex.

ForinformationonhowfixedrowIDsaffectheapoperations,see"Deletingfromadata-onlylockedheaptable"and"Data-only-lockedheaptables".
Selectoperationsonheaps
Whenyouissueaselectqueryonaheap,andthereisnousefulnonclusteredindex,AdaptiveServermustscaneverydatapageinthetabletofindeveryrowthatsatisfiestheconditionsinthequery.Theremaybeonerow,manyrows,ornorowsthatmatch.
Allpages-lockedheaptables
Forallpages-lockedtables,AdaptiveServerreadsthefirstcolumninsysindexesforthetable,readsthefirstpageintocache,andfollowsthenextpagepointersuntilitfindsthelastpageofthetable.
Data-onlylockedheaptables
Sincethepagesofdata-only-lockedtablesarenotlinkedinapagechain,aselectqueryonaheaptableusesthetable'sOAMandtheallocationpagestolocatealltherowsinthetable.TheOAMpagepointstotheallocationpages,whichpointtotheextentsandpagesforthetable.1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>