Oracle 碎片 优化 一例
一个客户打过来的,说是碰到一个很奇怪的问题。在一张上千万记录的大表里,做一个SELECT * FROM lt;TAB_NAMEgt; WHERE ROWNUM
一个客户打过来的,说是碰到一个很奇怪的问题。在一张上千万记录的大表里,做一个SELECT * FROM call count cpu elapsed disk query currentrows ------- ------ -------- ---------- -------------------- ---------- ---------- Parse 1 0.14 0.17 44 198 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 8 3.71 5.86 67489 68340 0 99 ------- ------ -------- -------------------- ---------- ---------- ---------- total 10 3.85 6.03 67533 68538 0 99 从这上面看,确实产生了67533个物理读和68538个逻辑读。执行时间为6.03秒。从等待事件来看: BINDS #39: EXEC #39:c=0,e=88,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1422207486718 WAIT #39: nam='SQL*Net message to client'ela= 7 driver id=1650815232 #bytes=1 p3=0 obj#=206418 tim=1422207486810 WAIT #39: nam='SQL*Net more data to client'ela= 203 driver id=1650815232 #bytes=2002 p3=0 obj#=206418 tim=1422207487071 WAIT #39: nam='SQL*Net more data to client'ela= 66 driver id=1650815232 #bytes=2020 p3=0 obj#=206418 tim=1422207487175 WAIT #39: nam='db file scattered read' ela=515 file#=146 block#=92900 blocks=5 obj#=206418 tim=1422207488208 WAIT #39: nam='db file scattered read' ela=918 file#=146 block#=92905 blocks=8 obj#=206418 tim=1422207489579 WAIT #39: nam='db file scattered read' ela=2121 file#=146 block#=92914 blocks=7 obj#=206418 tim=1422207492091 WAIT #39: nam='db file scattered read' ela=617 file#=146 block#=92921 blocks=8 obj#=206418 tim=1422207493135 WAIT #39: nam='db file scattered read' ela=493 file#=146 block#=92930 blocks=7 obj#=206418 tim=1422207494016 WAIT #39: nam='db file scattered read' ela=1666 file#=147 block#=897417 blocks=8 obj#=206418 tim=1422207496049 WAIT #39: nam='db file scattered read' ela=1026 file#=147 block#=897426 blocks=7 obj#=206418 tim=1422207497350 WAIT #39: nam='db file scattered read' ela=378 file#=147 block#=897433 blocks=8 obj#=206418 tim=1422207498049 WAIT #39: nam='db file scattered read' ela=1075 file#=147 block#=897442 blocks=7 obj#=206418 tim=1422207499416 WAIT #39: nam='db file scattered read' ela=1649 file#=147 block#=897449 blocks=3 obj#=206418 tim=1422207501237 WAIT #39: nam='db file scattered read' ela=2768 file#=147 block#=897453 blocks=4 obj#=206418 tim=1422207504191 WAIT #39: nam='db file scattered read' ela=653 file#=147 block#=897458 blocks=7 obj#=206418 tim=1422207505141 WAIT #39: nam='db file scattered read' ela=1588 file#=147 block#=897465 blocks=8 obj#=206418 tim=1422207507029 WAIT #39: nam='db file scattered read' ela=460 file#=147 block#=897474 blocks=7 obj#=206418 tim=1422207507787 WAIT #39: nam='db file scattered read' ela=608 file#=147 block#=897481 blocks=8 obj#=206418 tim=1422207508697 WAIT #39: nam='db file scattered read' ela=564 file#=147 block#=897490 blocks=7 obj#=206418 tim=1422207509571 WAIT #39: nam='db file scattered read' ela=832 file#=147 block#=897497 blocks=8 obj#=206418 tim=1422207510668 WAIT #39: nam='db file scattered read' ela=846 file#=148 block#=102411 blocks=16 obj#=206418 tim=1422207512030 WAIT #39: nam='db file scattered read' ela=4872 file#=148 block#=102427 blocks=16 obj#=206418 tim=1422207517488 WAIT #39: nam='db file scattered read' ela=1624 file#=148 block#=102443 blocks=16 obj#=206418 tim=1422207520062 确实存在大量的DB FILE SCATTERD READ。这更加坚信了我的观点,表里存在大量的碎片。找第一个SCATTERD READ的参数 file#=146 block#=92900,让客户执行alter system dump datafile 146 block min 92900 block max 92904。
获得的结果如下:
data_block_dump,data header at0x6000000000208e64
===============
tsiz: 0x1f98
hsiz: 0x4c
pbl: 0x6000000000208e64
bdba: 0x24816ae4 76543210
flag=--------
ntab=1
nrow=29
frre=0
fsbo=0x4c
fseo=0xf7
avsp=0x1f4c
tosp=0x1f4c
0xe:pti[0] nrow=29 offs=0
0x12:pri[0] sfll=1
0x14:pri[1] sfll=2
0x16:pri[2] sfll=3
0x18:pri[3] sfll=4
0x1a:pri[4] sfll=5
0x1c:pri[5] sfll=6
0x1e:pri[6] sfll=7
0x20:pri[7] sfll=8
0x22:pri[8] sfll=9
0x24:pri[9] sfll=10
0x26:pri[10] sfll=11
0x28:pri[11] sfll=12
0x2a:pri[12] sfll=13
0x2c:pri[13] sfll=14
0x2e:pri[14] sfll=15
0x30:pri[15] sfll=16
0x32:pri[16] sfll=17
0x34:pri[17] sfll=18
0x36:pri[18] sfll=19
0x38:pri[19] sfll=20
0x3a:pri[20] sfll=21
0x3c:pri[21] sfll=22
0x3e:pri[22] sfll=23
0x40:pri[23] sfll=24
0x42:pri[24] sfll=25
0x44:pri[25] sfll=26
0x46:pri[26] sfll=27
0x48:pri[27] sfll=28
0x4a:pri[28] sfll=-1
block_row_dump:
end_of_block_dump
里面全部是空块。建议客户做一个ALTER TABLE

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

蘋果公司最新發布的iOS18、iPadOS18以及macOSSequoia系統為Photos應用程式增添了一項重要功能,旨在幫助用戶輕鬆恢復因各種原因遺失或損壞的照片和影片。這項新功能在Photos應用的"工具"部分引入了一個名為"已恢復"的相冊,當用戶設備中存在未納入其照片庫的圖片或影片時,該相冊將自動顯示。 "已恢復"相簿的出現為因資料庫損壞、相機應用未正確保存至照片庫或第三方應用管理照片庫時照片和視頻丟失提供了解決方案。使用者只需簡單幾步

Hibernate多態映射可映射繼承類別到資料庫,提供以下映射類型:joined-subclass:為子類別建立單獨表,包含父類別所有欄位。 table-per-class:為子類別建立單獨資料表,僅包含子類別特有列。 union-subclass:類似joined-subclass,但父類別表聯合所有子類別列。

PHP處理資料庫連線報錯,可以使用下列步驟:使用mysqli_connect_errno()取得錯誤代碼。使用mysqli_connect_error()取得錯誤訊息。透過擷取並記錄這些錯誤訊息,可以輕鬆識別並解決資料庫連接問題,確保應用程式的順暢運作。

如何在PHP中使用MySQLi建立資料庫連線:包含MySQLi擴充(require_once)建立連線函數(functionconnect_to_db)呼叫連線函數($conn=connect_to_db())執行查詢($result=$conn->query())關閉連線( $conn->close())

可以透過使用gjson函式庫或json.Unmarshal函數將JSON資料儲存到MySQL資料庫中。 gjson函式庫提供了方便的方法來解析JSON字段,而json.Unmarshal函數需要一個目標類型指標來解組JSON資料。這兩種方法都需要準備SQL語句和執行插入操作來將資料持久化到資料庫中。

在Golang中使用資料庫回呼函數可以實現:在指定資料庫操作完成後執行自訂程式碼。透過單獨的函數新增自訂行為,無需編寫額外程式碼。回調函數可用於插入、更新、刪除和查詢操作。必須使用sql.Exec、sql.QueryRow或sql.Query函數才能使用回呼函數。

PHP連接資料庫指南:MySQL:安裝MySQLi擴展,建立連線(servername、username、password、dbname)。 PostgreSQL:安裝PgSQL擴展,建立連線(host、dbname、user、password)。 Oracle:安裝OracleOCI8擴展,建立連線(servername、username、password)。實戰案例:取得MySQL資料、PostgreSQL查詢、OracleOCI8更新記錄。

在C++中使用DataAccessObjects(DAO)函式庫連接和操作資料庫,包括建立資料庫連線、執行SQL查詢、插入新記錄和更新現有記錄。具體步驟為:1.包含必要的函式庫語句;2.開啟資料庫檔案;3.建立Recordset物件執行SQL查詢或操作資料;4.遍歷結果或依照特定需求更新記錄。
