🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.database
Article #400

SQL Server����Ƹ������α���

#400
From: Galaxy��VOLUNTEERS��Database
Date: Fri, 27 Mar 2009 02:34
100 lines
6216 bytes
���������һ���α�����ص����⣬�򵥵�˵���Ǻ�http://support.microsoft.com/
kb/953948��ص�

���⣬ĿǰΪֹʹ��Read Uncommitted���Եõ��ȽϺõ����飬���ͻ�����Ҫ����ݣ�
����������������

�취����ǰһֱ��Ϊ�����α�Ч�ʵ;�û��ô�����о��������Ҫ̸��˳���ᵽ�α�
��

1. �����
�������ڽ��������Դ���С�ҳ���?�����á���Ҫ�ǽ�������������⣺
a. ���������
b. ���û������޸�ʱ��ô����
�����ǽ���ò���������������ʲô�����⣩
����b�����Ҫ���������ơ�

�������ƣ�
��Ϊ�����ֹۺͱ��ۡ�
���۾��ǺܰԵ��ذ����ռΪ���У�ֱ���Լ�Ը����֡�������ݷdz����֣�high 
contention of data��

������¡�
�ֹ۾��Ǻܴ󷽵ع�����ݣ���A�û��ύ��ݵĸ�������ϵͳ�ȼ�������Dz�����
A�û���֮���Ѿ�

���޸Ĺ��ˡ�����Ѿ����޸Ĺ�Ļ��ͱ��?�ع�A�ĸ�������
˳��˵�£�API����Ҳ����ADO, ADO.NET, OLE DB��ODBCҲ���Խ��в������ơ�

������������������뼶����ġ�������˵����������������޸ĵ���ʱ���Ƿ��أ�
1. ����ס��ֱ�����������ͷţ�Serializable����ߵȼ���
2. ��������������֮ǰ�İ汾��Read committed ����ݿ�Ĭ�ϣ�
3. ������������û���ύ�İ汾��Read uncommitted ����͵ȼ���
����һ��Repeatable read��Read committed�ȼ��Եͣ����ܻ��ظ���

2. ��
һ�㲻������Ҫ����������SQL Server��ݿ������lock manager�������Զ�����
��˵������Ҫ����

��
Shared (S)  ��������Դ�ϴ���S���κ��������񶼲����޸����
Update (U)  �������ֹ��Ựͬʱ��������������������������ʱ��һ������
���S���X

������ת��������Ҫһ����ʱ�䣬���ǾͿ��ܳ�����������ת��ΪX��ȴ�Է�
�ͷ�S�������

��Ϊ�˱������⣬���ʹ��U��һ��ֻ��һ��������Ի��U��
Exclusive (X)   �������ֹ�������ͬʱ�����ã��κ����������޷��޸����
Intent��I�� �������������IS��IX��SIX�����ڷ�ֹ��������ʹ�ϵͼ����������
Ч�ķ�ʽ�޸�

�߼�����߼�����ͻЧ��
Schema��Sch-S�� �ܹ���ִ�������ڱ�ܹ��IJ���ʱ�������֣����޸� (Sch-M) ��
�ܹ��ȶ��� (Sch

-S)��

Ҫ�������ص���Ϣ������ʹ�����µķ�����
1. SQL Server Profiler
������Event��ѡ�����
2. sys.dm_tran_locks 
DMV��ʽ
3. sp_lock����ǰ������sp_lock2����
�����ݵ����ԣ�����ͦ���ã�����sys.syslockinfo 
������SMO��DMO�����ȡ�

���������������Բο������ᵽ��U��SQL Server�������������������⵽ѭ��
������ϵ��ѡ����

�е�һ����Ϊ����Ʒ�������������������ֹ������ʾ����

3. ���
�α����Ͳ�ͬ��ʽҲ��ͬ��
��̬�α���ÿһ�С�
��̬�α�ֻ����ȡ��ʱ�Ż�ȡ��
�α��ύʱ����ѡ��ر�Ҳ����ѡ�����򿪡���CURSOR_CLOSE_ON_COMMIT�����ơ�

�����α�IJ������ƣ�SQL Server���ĸ�ѡ�
READ_ONLY
������ͨ���α���ж�λ����
OPTIMISTIC WITH VALUES
T-SQL�α겻֧�֡��ֹ۲������ơ����α�͸��µļ�����������̽��и��¡�
OPTIMISTIC WITH ROW VERSIONING
T-SQL�α겻֧�֡��ֹ۲������ơ�����timestamp
SCROLL LOCKS�����۲�������

�ȼ����?�����ϸ�ڵ��Ժ��л���ٲ��䡣

�ο����ϣ�
Locking and Row Versioning 
http://msdn.microsoft.com/en-us/library/ms187101.aspx

Cursor Locking 
http://msdn.microsoft.com/en-us/library/aa172580.aspx 
--
Welcome to Database Board
��ӭ������ݿ��
http://bbs.sjtu.edu.cn/bbsdoc?board=database

�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 207.46.55.28]
Technical Details
Message-ID: <4fBJ10$aij@bbs.sjtu.edu.cn>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news.neu.edu.cn!news.shec6.edu.cn!SJTU

Show Full Headers
Complete Article Headers
X-Google-Thread: 101948,710a23fdef2c1fe6,start
X-Google-Attributes: gid101948,domainid0,public,usenet
X-Google-Language: Chinese,GB
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news.neu.edu.cn!news.shec6.edu.cn!SJTU
From: Dem.bbs@bbs.sjtu.edu.cn (Galaxy��VOLUNTEERS��Database)
Newsgroups: cn.bbs.comp.database
Subject: SQL Server����Ƹ������α���
Date: 27 Mar 2009 02:34:31 GMT
Organization: ��ˮ˼Դ
Message-ID: <4fBJ10$aij@bbs.sjtu.edu.cn>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: database/M.1238121264.A