freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

數(shù)據(jù)庫(kù)實(shí)驗(yàn)-資料下載頁(yè)

2025-10-12 10:47本頁(yè)面
  

【正文】 需要傳輸 64 kb 以上的 sql 數(shù)據(jù)時(shí),盡可能地執(zhí)行 64 kb 磁盤(pán)傳輸是有益的,即分成數(shù)個(gè)64k的操作。因?yàn)?64 kb 傳輸基本上與 8 kb 傳輸一樣快,而每次傳輸?shù)?sql server 數(shù)據(jù)是 8 kb 傳輸?shù)?8 倍。我們通過(guò)一個(gè)實(shí)例來(lái)看 有and 操作符時(shí)候的最常見(jiàn)的一種情況。我們有下面一個(gè)表,create table [dbo].[member]([member_no] [dbo].[numeric_id] identity(1,1)not null, [lastname] [dbo].[shortstring] not null, [firstname] [dbo].[shortstring] not null, [middleinitial] [dbo].[letter] null, [street] [dbo].[shortstring] not null, [city] [dbo].[shortstring] not null, [state_prov] [dbo].[statecode] not null, [country] [dbo].[countrycode] not null, [mail_code] [dbo].[mailcode] not null, [phone_no] [dbo].[phonenumber] null, [photograph] [image] null, [issue_dt] [datetime] not null default(getdate()), [expr_dt] [datetime] not null default(dateadd(year,1,getdate())), [region_no] [dbo].[numeric_id] not null, [corp_no] [dbo].[numeric_id] null, [prev_balance] [money] null default(0), [curr_balance] [money] null default(0), [member_code] [dbo].[status_code] not null default(39。 39。))這個(gè)表具備下面的四個(gè)索引:索引名 細(xì)節(jié) 索引的列member_corporation_link nonclustered located on primary corp_nomember_ident clustered, unique, primary key located on primary member_nomember_region_link nonclustered located on primary region_nomemberfirstname nonclustered located on primary firstname當(dāng)我們執(zhí)行下面的sql查詢(xún)時(shí)候,select , , as mwhere like 39。k%39。 and 6 and 5000gosql server 會(huì)根據(jù)索引方式,優(yōu)化成下面方式來(lái)執(zhí)行。select ,(select , from as m where like 39。k%39。 and 5000)a ,這個(gè)查詢(xún)可以直接使用 memberfirstname 非聚集索引,而且這個(gè)非聚集索引覆蓋了所有查詢(xún)列實(shí)際執(zhí)行時(shí),只需要 邏輯讀取 3 次(select , from as mwhere 6)b這個(gè)查詢(xún)可以直接使用 member_region_link 非聚集索引,而且這個(gè)非聚集索引覆蓋了所有查詢(xún)列實(shí)際執(zhí)行時(shí),只需要 邏輯讀取 10 次where = 不信,你可以看這兩個(gè)sql 的執(zhí)行計(jì)劃,以及邏輯讀信息,都是一樣的。其實(shí)上面的sql,如果優(yōu)化成下面的方式,實(shí)際的邏輯讀消耗也是一樣的。為何sql server 不會(huì)優(yōu)化成下面的方式。是因?yàn)?and 操作符優(yōu)化的另外一個(gè)原則。1/26 的數(shù)據(jù)和 1/6 的數(shù)據(jù)找交集的速度要比 1/52 的數(shù)據(jù)和 1/3 的數(shù)據(jù)找交集速度要慢。select ,(select , from as mwhere like 39。k%39。1/26 數(shù)據(jù))a,(select , from as mwhere 6 and 50001/3 * 1/ 2 數(shù)據(jù))bwhere = 當(dāng)然,我們要學(xué)習(xí)sql 如何優(yōu)化的話(huà),就會(huì)用到查詢(xún)語(yǔ)句中的一個(gè)功能,指定查詢(xún)使用哪個(gè)索引來(lái)進(jìn)行。比如下面的查詢(xún)語(yǔ)句select , , as m with(index(0))where like 39。k%39。 and 6 and 5000goselect , , as m with(index(1))where like 39。k%39。 and 6 and 5000goselect , , as m with(index(membercovering3))where like 39。k%39。 and 6 and 5000goselect , , as m with(index(memberfirstname, member_region_link))where like 39。k%39。 and 6 and 5000go這里 index 計(jì)算符可以是 0,1,指定的一個(gè)或者多個(gè)索引名字。對(duì)于 0,1 的意義如下:如果存在聚集索引,則 index(0)強(qiáng)制執(zhí)行聚集索引掃描,index(1)強(qiáng)制執(zhí)行聚集索引掃描或查找(使用性能最高的一種)。如果不存在聚集索引,則 index(0)強(qiáng)制執(zhí)行表掃描,index(1)被解釋為錯(cuò)誤??偨Y(jié)知識(shí)點(diǎn):簡(jiǎn)單來(lái)說(shuō),我們可以這么理解:sql server 對(duì)于每一條查詢(xún)語(yǔ)句。會(huì)根據(jù)實(shí)際索引情況(sysindexes 系統(tǒng)表中存儲(chǔ)這些信息),分析每種組合可能的成本。然后選擇它認(rèn)為成本最小的一種。作為它實(shí)際執(zhí)行的計(jì)劃。成本代價(jià)計(jì)算的一個(gè)主要組成部分是邏輯i/o的數(shù)量,特別是對(duì)于單表的查詢(xún)。and 操作要滿(mǎn)足所有條件,這樣,經(jīng)常會(huì)要求對(duì)幾個(gè)數(shù)據(jù)集作交集。數(shù)據(jù)集越小,數(shù)據(jù)集的交集計(jì)算越節(jié)省成本。的項(xiàng)目中,竟然出現(xiàn)了濫用聚集索引的問(wèn)題??磥?lái)沒(méi)有培訓(xùn)最最基礎(chǔ)的索引的意義,代價(jià),使用場(chǎng)景,是一個(gè)非常大的失誤。這篇博客就是從這個(gè)角度來(lái)羅列索引的基礎(chǔ)知識(shí)。使用索引的意義索引在數(shù)據(jù)庫(kù)中的作用類(lèi)似于目錄在書(shū)籍中的作用,用來(lái)提高查找信息的速度。使用索引查找數(shù)據(jù),無(wú)需對(duì)整表進(jìn)行掃描,可以快速找到所需數(shù)據(jù)。使用索引的代價(jià)索引需要占用數(shù)據(jù)表以外的物理存儲(chǔ)空間。創(chuàng)建索引和維護(hù)索引要花費(fèi)一定的時(shí)間。當(dāng)對(duì)表進(jìn)行更新操作時(shí),索引需要被重建,這樣降低了數(shù)據(jù)的維護(hù)速度。創(chuàng)建索引的列主鍵外鍵或在表聯(lián)接操作中經(jīng)常用到的列在經(jīng)常查詢(xún)的字段上最好建立索引不創(chuàng)建索引的列很少在查詢(xún)中被引用包含較少的惟一值定義為 text、ntext 或者 image 數(shù)據(jù)類(lèi)型的列heaps是staging data的很好選擇,當(dāng)它沒(méi)有任何index時(shí)excellent for high performance data loading(parallel bulk load and parallel index creation after load)excellent as a partition to a partitioned view or a partitioned table聚集索引提高性能的方法,在前面幾篇博客中分別提到過(guò),下面只是一個(gè)簡(jiǎn)單的大綱,細(xì)節(jié)請(qǐng)參看前面幾篇博客。何時(shí)創(chuàng)建聚集索引?clustered index會(huì)提高大多數(shù)table的性能,尤其是當(dāng)它滿(mǎn)足以下條件時(shí):獨(dú)特, 狹窄, 靜止: 最重要的條件持續(xù)增長(zhǎng)的,最好是只向上增加。例如:identitydate, identityguid(only when using newsequentialid()function)聚集索引唯一性(獨(dú)特型的問(wèn)題)由于聚集索引的b+樹(shù)結(jié)構(gòu)的葉子節(jié)點(diǎn)必須指向具體數(shù)據(jù)。如果你要建立聚集索引的列不唯一,并且你指定的創(chuàng)建的聚集索引是非唯一的聚集索引,則會(huì)有以下情況:如果未使用 unique 屬性創(chuàng)建聚集索引,數(shù)據(jù)庫(kù)引擎 將向表自動(dòng)添加一個(gè)四字節(jié) uniqueifier 列。必要時(shí),數(shù)據(jù)庫(kù)引擎 將向行自動(dòng)添加一個(gè) uniqueifier 值,使每個(gè)鍵唯一。此列和列值供內(nèi)部使用,用戶(hù)不能查看或訪(fǎng)問(wèn)。
點(diǎn)擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1