สวัสดีครับผมเป็นนักศึกษาไปฝึกงาน

ได้รับมอบหมายให้ศึกษาวิธีทำให้ database ที่ใช้ MS server 2005 สามารถ query ได้เร็วขึ้น (เพราะหลายครั้ง query แล้ว timeout)

ส่วนที่ทำให้เกิดปัญหาหลักๆ

  • table ประมาณ 5 อันที่มี record ประมาณ 400k+
  • เวลาเรียกใช้ จะมีการเรียกใช้โดย ผ่าน view หรือดู table โดยตรง ซึ่งจะมีการ join กัน

ลักษณะการใช้

  • readonly
  • ข้อมูลจะเพิ่มขึ้นตามเวลา (จะมีบริษัทที่ outsource มีเทข้อมูลใส่ให้ครับ)
  • ข้อมูลที่เก็บตั้งแต่ปี 2004
  • การเรียกดูส่วนใหญ่จะเรียกดูข้อมูลใน 3 ปี ล่าสุด

เท่าที่ผม search ดู
SQL Profiler and the Index Tuning Wizard น่าจะช่วยได้ (ไม่ทราบใครเคยใช้บ้างครับ มันมีแถมมาจาก MS server 2005 หรือเปล่าครับ)
แต่เพื่อนบอกว่า ไม่แน่ใจว่าใน DB ที่ใหญ่ขนาดนี้ การทำ index จะช่วยได้แค่ไหนครับ

ใครมีคำแนะนำอะไรโปรดบอกผมทีนะครับ ขอบคุณมากครับ

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

paepod Mon, 20/04/2009 - 07:26

ทำ INDEX เลยครับผม ช่วยได้แน่นอน ที่เหลือ รอท่านอื่นมาตอบ

tekkasit Mon, 20/04/2009 - 09:14

ดู search criteria กับ data profile เพื่อวิเคราะห์ว่าจะทำ index กับรายการอะไรบ้าง ซึ่งมีทางเลือกระหว่าง compound index กับ index บนหนึ่งฟิลด์ แต่มีหลายๆตัว

ในกรณีนี้ ระบบมันเป็น read-only แบบ warehouse ใส่ index ได้เยอะ ผลกระทบน้อย แต่ถ้าเป็นระบบที่เป็น operation มีการอัพเดทบ่อยๆ ใส่ index เยอะๆ ระดับสิบตัวขึ้นไป นี่มีผลกระทบบ้าง

ในรุ่น SQL Server 2005 รองรับการทำ partitioning แล้ว ลองดูว่าจะใช้คีย์อะไรในการทำการแบ่งข้อมูล เช่น ปีของข้อมูล

ZiiT Mon, 20/04/2009 - 09:26

ลองดูว่าส่วนใหญ่ Where Cause ที่ใช้ตกลงบน Key ที่มี Index อยู่รึป่าวครับ ถ้าไม่มีก็เพิ่ม Index น่าจะช่วยได้

แล้วก็ลองมองเรื่อง Cluster Index ว่า ส่วนใหญ่ถ้าเปลี่ยนการจัดเรียงของ Physical จะช่วยได้มั๊ย อันนี้ขึ้นอยู่กับลักษณะของการ Select ว่า Cluster Index บน Key อะไรช่วยให้เกิดประสิทธิภาพมากที่สุดครับ :)

อีกเรื่องนึง ลองดูเรื่องความถูกต้องของข้อมูล พวก Isolation Level ซึ่งบาง Statement เราอาจจะเพิ่ม with (nolock) (สำหรับ MSSQL)เข้ามาช่วยได้อาจจะทำให้ทำงานำได้เร็วขึ้นครับ (แต่อันนี้อาจจะไปกระทบกับส่วน Develop)

NgOrXz Mon, 20/04/2009 - 18:13

Index ครับ ช่วยได้เยอะครับ

©NgOrXz™®
แมนเชสเตอร์ยูไนเต็ด เก่งที่สุดในโลก

godzilla Mon, 04/05/2009 - 08:20

ถ้ามี h/w (disk) เยอะ กระจาย i/o ให้มากๆ
ถ้ามีการ sort สังเกต tempdb ให้ดีๆ ว่าเพียงพอหรือไม่
อยู่บน disk ลูกเดียวกับ data หรือไม่

พึงระลึกไว้เสมอว่า performance tuning ไม่เสร็จในครั้งเดียว
ต้องทำและสังเกตผลอย่างต่อเนื่อง