วันอังคารที่ 14 มกราคม พ.ศ. 2557

เพิ่มประสิทธิภาพ ของ SQL Server DB

เพิ่มประสิทธิภาพ ของ SQL Server DB
Posted on 15/05/2012

เริ่มด้วยการย้าย TempDB

เราทำการย้าย TempDB ไปยัง Disk อื่น ที่ไม่ใช่ Disk ที่ใช้ติดตั้ง SQL Server เพื่อเพิ่มประสิทธฺิภาพในการอ่าน/เขียน ให้มากขึ้น

โดยเราจะทำการย้ายไปยังไดรฟ์ E: ครับ



ทำได้ยังไง

พิมพ์ Script ด้านล่างนี้ครับ



use master;
go
alter database tempdb
modify file (name = tempdev, filename = ‘e:\temp\tempdb.mdf’);
go
alter database tempdb
modify file (name = templog, filename = ‘e:\temp\templog.ldf’);



เมื่อเสร็จแล้วจะได้ Message คล้าย ๆ กับข้างล่างนี้ แปลว่าเสร็จสิ้นการย้าย แต่จะต้องทำการ Restart Database ก่อน จึงจะใช้ได้ครับ

The file “tempdev” has been modified in the system catalog. The new path will be used the next time the database is started.
The file “templog” has been modified in the system catalog. The new path will be used the next time the database is started.




พอเวลาที่เราใช้ DB ไปนาน ๆ แล้วข้อมูลจะเยอะขึ้นและทำให้มีปัญหาในการเข้าถึงข้อมูลที่ต้องการ หรือง่าย ๆ ก็คือมันช้านั้นเอง

ดังนั้นเราจึงควรที่จะทำ

ทำการ Reindex Table

วิธีนี้เราจะสามารถทำได้ทีละ Table นะครับ โดยจะต้องทำดังนี้



use Northwind ;
go
dbcc dbreindex (customers)

go



แล้วจะได้ Message ประมาณนี้ แปลว่าเสร็จพิธี

DBCC execution completed. If DBCC printed error messages, contact your system administrator.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น