今天陪同新來(lái)的DB2 DBA上線,他問(wèn)了我?guī)讉€(gè)問(wèn)題,我總結(jié)了一下,雖然很簡(jiǎn)單,但是貌似我多年之前也遇到過(guò),疑惑過(guò)。
對(duì)數(shù)據(jù)庫(kù)的幾個(gè)千萬(wàn)行級(jí)別大表加了列,做了offline reorg操作,幾分鐘以后,沒(méi)有做完,開(kāi)始問(wèn)我,怎么看現(xiàn)在運(yùn)行到哪里了,多長(zhǎng)時(shí)間能做完。
對(duì)于第一個(gè)問(wèn)題,比較容易用db2pd看,每5秒看一次輸出
db2pd -d DBNAME -reorg -rep 5
站在用戶(hù)的角度思考問(wèn)題,與客戶(hù)深入溝通,找到長(zhǎng)順網(wǎng)站設(shè)計(jì)與長(zhǎng)順網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶(hù)體驗(yàn)好的作品,建站類(lèi)型包括:成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、申請(qǐng)域名、網(wǎng)絡(luò)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋長(zhǎng)順地區(qū)。
這里不得不提到的DB2的offline reorg分成幾步走,從上面的輸出可以看到 Build,IdxRecreat 這2步
實(shí)際可能有更多步,要看reorg用的命令和表有沒(méi)有cluster index,以下是詳細(xì)解釋
There are four phases in a classic or offline table reorganization:
(1) SORT: If an index is specified with the REORG TABLE command, or if a clustering index is defined on the table, the rows of the table are first sorted according to that index. If the INDEXSCAN option is specified, an index scan is used to sort the table, otherwise, a table scan sort is used. This phase only applies to a clustering REORG. Space reclaiming reorganizations begin at the build phase.
(2) BUILD: In this phase, a reorganized copy of the entire table is build, either in the table space that the table being reorganized resides, or in a temporary table space specified with the REORG command.
(3) REPLACE: In this phase, the original table object is replaced by either copying back from the temporary table space, or by pointing to the newly built object within the table space of the table being reorganized.
(4) RECREATE ALL INDEXES: All indexes defined on the table are recreated
估計(jì)一下運(yùn)行時(shí)間的問(wèn)題,最好是參考之前的REORG的時(shí)間
select START_TIME,END_TIME from sysibmadm.db_history where OPERATION='G' and OPERATIONTYPE='F' and TABNAME='XXXXXXXXX'
每次數(shù)據(jù)庫(kù)的變更,在組里面討論的時(shí)候,都要估計(jì)一下變更所需要的時(shí)間,對(duì)于普通的SQL和DDL來(lái)說(shuō),時(shí)間消耗很小,如果涉及幾個(gè)大表的reorg & runstats操作,如果不事先做調(diào)查往往估計(jì)和實(shí)際有很大的出入,可能事情做完會(huì)被challenge。這就是吃力不討好。關(guān)鍵還是自己沒(méi)有做細(xì)致。
Reorg之后,做runstats,繼續(xù)用db2pd 觀察 db2pd -d DBNAME -runstats
順便說(shuō)一句,用了幾種數(shù)據(jù)庫(kù),在做監(jiān)控方面,db2pd是我最喜歡的,使用簡(jiǎn)單,現(xiàn)在可以監(jiān)控的東西非常多,非常不喜歡用SQL做監(jiān)控的方式,在客戶(hù)現(xiàn)場(chǎng),真心沒(méi)有空寫(xiě)SQL,尤其是問(wèn)題比較著急的時(shí)候。
DB2的新版本中加入了更多可以用db2pd監(jiān)控的內(nèi)容,希望db2pd能越來(lái)越考慮實(shí)際需要,增加更多的監(jiān)控參數(shù)吧。
當(dāng)前標(biāo)題:DB2offlinereorg的一點(diǎn)筆記
網(wǎng)頁(yè)路徑:http://aaarwkj.com/article36/pjcgpg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、移動(dòng)網(wǎng)站建設(shè)、面包屑導(dǎo)航、網(wǎng)站改版、自適應(yīng)網(wǎng)站、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)