久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機(jī)端+微網(wǎng)站+自適應(yīng)網(wǎng)頁多模板選擇-建站388元起價(jià)!!!
當(dāng)前位置:主頁 > 網(wǎng)站建設(shè) > 關(guān)于重新組織和重新生成索引sp_RefreshIndex的介紹

關(guān)于重新組織和重新生成索引sp_RefreshIndex的介紹

時(shí)間:2023-05-23 22:05:23 閱讀: 文章分類: 網(wǎng)站建設(shè) 作者: 建站小能手

導(dǎo)讀:1建站知識本篇文章小編為大家介紹,關(guān)于重新組織和重新生成索引sp_RefreshIndex的介紹。需要的朋友參考下百度seo網(wǎng)站優(yōu)化網(wǎng)站seo優(yōu)化。

百度seo網(wǎng)站優(yōu)化網(wǎng)站seo優(yōu)化

開始:

--------------------------------------------------------------------------------

在上周,客戶反映一個(gè)系統(tǒng)問題,當(dāng)處理大量數(shù)據(jù)的時(shí)候,出現(xiàn)網(wǎng)絡(luò)超時(shí)。后來,我們跟蹤測試,發(fā)現(xiàn)是由于索引碎片多而引起的網(wǎng)絡(luò)超時(shí)。

解決方法,自然是重新組織和重新生成索引。在這里,我寫了一個(gè)存儲過程sp_RefreshIndex來實(shí)現(xiàn)。

存儲過程sp_RefreshIn網(wǎng)站建設(shè)多少錢dex:

復(fù)制代碼 代碼如下:

use mastergoif object_id('sp_RefreshIndex') Is not null Drop Proc sp_RefreshIndexGocreate proc sp_RefreshIndex ( @Reorganize_Fragmentation_Percent smallint = 5 -- 當(dāng)邏輯碎片百分比 > 5% 重新組織索引 ,@Rebuild_Fragmentation_Percent smallint = 30 -- 當(dāng)邏輯碎片百分比 > 30% 重新生成索引)asbegin /* 調(diào)用方法:.針對當(dāng)前實(shí)例所有數(shù)據(jù)庫: exec sys.sp_MSforeachdb 'use ?;exec sp_RefreshIndex'.針對當(dāng)前數(shù)據(jù)庫: exec sp_RefreshIndex */ --對系統(tǒng)數(shù)據(jù)庫不作重新組織索引和重新生成索引 if (db_name() in ('ma網(wǎng)站優(yōu)化seo培訓(xùn)ster','model','msdb','tempdb')) return; --如果邏輯碎片(索引中的無序頁)的百分比 <= 5% ,就不作重新組織索引和重新生成索引 if not exists(select 1 from sys.dm_db_index_physical_stats(db_id(),null,null,null,null) a where a.index_id>0 and a.avg_fragmentation_in_percent > @Reorganize_Fragmentation_Percent) return print replicate('-',60)+char(13)+char(10)+replicate(' ',14)+N'對數(shù)據(jù)庫 '+quotename(db_name())+N' 進(jìn)行索引優(yōu)化'+replicate(' ',20)+char(13)+char(10) declare @sql nvarchar(2000),@str nvarchar(2000) declare cur_x cursor for select 'alter index '+quotename(a.name)+' on '+quotename(object_schema_name(網(wǎng)seo優(yōu)化趨勢a.object_id))+'.'+quotename(object_name(a.object_id))+case when b.avg_fragmentation_in_percent<=@Rebuild_Fragmentation_Percent then ' reorganize;'else ' rebuild;'end as [sql] ,case when b.avg_fragmentation_in_percent<=@Rebuild_Fragmentation_Percent then N'重新組織索引:' else N'重新生成索引:'end +quotename(object_schema_name(a.object_id))+'.'+quotename(object_name(a.object_id))+'.'+quotename(a.name) as [str] from sys.indexes a inner join sys.dm_db_index_physical_stats(db_id(),null,null,null,null) b on b.object_id=a.object_id and b.index_id=a.index_id where a.index_id>0 and b.avg_fragmentation_in_percent > @Reorganize_Fragmentation_Percent order by object_name(a.object_id),a.index_id open cur_x fetch next from cur_x into @sql,@str while (@@fetch_status = 0) begin exec(@sql) print @str fetch next from cur_x into @sql,@str end close cur_x deallocate cur_x endgoexec sp_ms_marksystemobject 'sp_RefreshIndex'go

關(guān)鍵詞標(biāo)簽: 標(biāo)簽 索引

聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-23 ,文章關(guān)于重新組織和重新生成索引sp_RefreshIndex的介紹主要講述索引,標(biāo)簽,關(guān)于重新組織和重新生成索引sp_Refre網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_6086.html

我的IDC 網(wǎng)站建設(shè)技術(shù)SEOUC.COM
專注網(wǎng)站建設(shè),SEO優(yōu)化,小程序設(shè)計(jì)制作搭建開發(fā)定制網(wǎng)站等,數(shù)千家網(wǎng)站定制開發(fā)案例,網(wǎng)站推廣技術(shù)服務(wù)。
  • 5000+合作客服
  • 8年從業(yè)經(jīng)驗(yàn)
  • 150+覆蓋行業(yè)
  • 最新熱門源碼技術(shù)文章

    主站蜘蛛池模板: 中牟县| 沙田区| 朝阳县| 堆龙德庆县| 清苑县| 东乡县| 兴宁市| 上思县| 永州市| 龙江县| 肥乡县| 开原市| 阿克苏市| 三都| 陆丰市| 靖州| 当阳市| 杭州市| 花莲县| 广水市| 邻水| 临漳县| 阿巴嘎旗| 江安县| 沽源县| 襄汾县| 信丰县| 江北区| 鲁甸县| 云林县| 灌南县| 民县| 邹城市| 霍山县| 澜沧| 砚山县| 榆树市| 兴安县| 新巴尔虎右旗| 龙岩市| 安平县|