SQLÐÔÄܵ÷УÃüÁî
DBCC DROPCLEANBUFFERS --Çå³ý»º³åÇø£¬±ãÓڶԱȲéѯʱ¼äºÍÐÔÄÜ£¬²»ÊÕ»º´æµÄÓ°Ïì
SET STATISTICS TIME ON --ÏÔʾ·ÖÎö¡¢±àÒëºÍÖ´Ðи÷Óï¾äËùÐèµÄºÁÃëÊý
sp_spaceused NSDoctorAdvice0705 -- ²é¿´±í¿Õ¼ä´óС
ÎÊÌâÌÖÂÛ£º
ÊÇ·ñÔö¼ÓÒ»¸ö¶ÀÁ¢µÄÎļþ×飬ÓÃÀ´´æ·ÅË÷Òý¡£Ä¿Ç°Êý¾Ý¿âµÄÖ»ÓÐÒ»¸öÎļþ×飬Îļþ·Ç³£´óµÄ»°£¬²éѯ»á±È½ÏÂý¡£
ÏÖÔÚÖ»Óõ½´´½¨Ë÷Òý£¬Ìá¸ßÐÔÄÜ¡£ÔÙ¿¼ÂÇ´´½¨Í³¼ÆÕâ¸ö¹¦ÄÜ£¬À´¸Ä½øÐÔÄÜ¡£
¶Ô1¸ö¾³£±»¸üеÄÁн¨Á¢Ë÷Òý£¬»áÑÏÖØÓ°ÏìÐÔÄÜ
·Ö´ØË÷Òý²»Ó¦¸Ã¹¹ÔìÔÚ¾³£±ä»¯µÄÁÐÉÏ£¬ÒòΪÕâ»áÒýÆðÕûÐеÄÒƶ¯
²»Òª¶ÔÓÐÏ޵ļ¸¸öÖµµÄ×ֶν¨µ¥Ò»Ë÷ÒýÈçÐÔ±ð×Ö¶Î
²éѯºÄʱºÍ×Ö¶ÎÖµ×ܳ¤¶È³ÉÕý±È,ËùÒÔ²»ÄÜÓÃCHARÀàÐÍ£¬¶øÊÇVARCHAR¡£
¶ÔÓÚ×ֶεÄÖµºÜ³¤µÄ½¨È«ÎÄË÷Òý¡£
DB Server ºÍAPPLication Server ·ÖÀë;OLTPºÍOLAP·ÖÀë [Õâ¸ö¼¼ÊõÒªºÃºÃÑо¿£¡]
×¢ÒâUNionºÍUNion all µÄÇø±ð¡£UNION allºÃ
20¡¢ÓÃsp_configure 'query governor cost limit'»òÕßSET QUERY_GOVERNOR_COST_LIMITÀ´ÏÞÖƲéѯÏûºÄµÄ×ÊÔ´¡£µ±ÆÀ¹À²éѯÏûºÄµÄ×ÊÔ´³¬³öÏÞÖÆʱ£¬·þÎñÆ÷×Ô¶¯È¡Ïû²éѯ,ÔÚ²éѯ֮ǰ¾Í¶óɱµô¡£ SET LOCKTIMEÉèÖÃËøµÄʱ¼ä
NOT IN»á¶à´ÎɨÃè±í£¬Ê¹ÓÃEXISTS¡¢NOT EXISTS £¬IN , LEFT OUTER JOIN À´Ìæ´ú£¬ÌرðÊÇ×óÁ¬½Ó,¶øExists±ÈIN¸ü¿ì£¬×îÂýµÄÊÇNOT²Ù×÷
Èç¹ûʹÓÃÁËIN»òÕßORµÈʱ·¢ÏÖ²éѯûÓÐ×ßË÷Òý£¬Ê¹ÓÃÏÔʾÉêÃ÷Ö¸¶¨Ë÷Òý£º Select * from PersonMember (INDEX = IX_Title) Where processid IN ('ÄÐ'£¬'Å®')
vi.¡¡¾¡Á¿Ê¹ÓÃexists´úÌæselect count(1)À´ÅжÏÊÇ·ñ´æÔڼǼ£¬countº¯ÊýÖ»ÓÐÔÚͳ¼Æ±íÖÐËùÓÐÐÐÊýʱʹÓ㬶øÇÒcount(1)±Ècount(*)¸üÓÐЧÂÊ¡£
¡¡44¡¢µ±·þÎñÆ÷µÄÄÚ´æ¹»¶àʱ£¬ÅäÖÆÏß³ÌÊýÁ¿ = ×î´óÁ¬½ÓÊý+5£¬ÕâÑùÄÜ·¢»Ó×î´óµÄЧÂÊ;·ñÔòʹÓà ÅäÖÆÏß³ÌÊýÁ¿<×î´óÁ¬½ÓÊýÆôÓÃSQL SERVERµÄÏ̳߳ØÀ´½â¾ö,Èç¹û»¹ÊÇÊýÁ¿ = ×î´óÁ¬½ÓÊý+5£¬ÑÏÖصÄË𺦷þÎñÆ÷µÄÐÔÄÜ¡£
xi.¡¡×¢Òâinsert¡¢update²Ù×÷µÄÊý¾ÝÁ¿£¬·ÀÖ¹ÓëÆäËûÓ¦ÓóåÍ»¡£Èç¹ûÊý¾ÝÁ¿³¬¹ý200¸öÊý¾ÝÒ³Ãæ(400k)£¬ÄÇôϵͳ½«»á½øÐÐËøÉý¼¶£¬Ò³¼¶Ëø»áÉý¼¶³É±í¼¶Ëø¡£
46¡¢Í¨¹ýSQL Server Performance Monitor¼àÊÓÏàÓ¦Ó²¼þµÄ¸ºÔØ Memory: Page Faults / sec¼ÆÊýÆ÷Èç¹û¸Ãֵż¶û×߸ߣ¬±íÃ÷µ±Ê±ÓÐÏ߳̾ºÕùÄÚ´æ¡£Èç¹û³ÖÐøºÜ¸ß£¬ÔòÄÚ´æ¿ÉÄÜÊÇÆ¿¾±¡£
¡¡¡¡Process:
¡¡¡¡1¡¢% DPC Time Ö¸ÔÚ·¶Àý¼ä¸ôÆڼ䴦ÀíÆ÷ÓÃÔÚ»ºÑÓ³ÌÐòµ÷ÓÃ(DPC)½ÓÊÕºÍÌṩ·þÎñµÄ°Ù·Ö±È¡£(DPC ÕýÔÚÔËÐеÄΪ±È±ê×¼¼ä¸ôÓÅÏÈȨµÍµÄ¼ä¸ô)¡£ ÓÉÓÚ DPC ÊÇ
Ïà¹ØÎĵµ£º
ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£ ......
¡¡¡¡1¡¢²é¿´±í¿Õ¼äµÄÃû³Æ¼°´óС
¡¡¡¡select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
¡¡¡¡from dba_tablespaces t, dba_data_files d
¡¡¡¡where t.tablespace_name = d.tablespace_name
¡¡¡¡group by t.tablespace_name;
¡¡¡¡
¡¡¡¡2¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ¼°´óС
¡¡¡¡select tablesp ......
SQL Server Filtered Indexes - What They Are, How to Use and Performance Advantages
Written By: Arshad Ali -- 7/2/2009 -
Problem
SQL Server 2008 introduces Filtered Indexes which is an index with a WHERE clause. Doesn’t it sound awesome especially for a table that has huge amount of data and ......
ÕâÊÇÎÒ±ßѧ±ß×ܽáµÄ£¬×ܹ²»¨ÁËÒ»ÌìÒ»Ò¹µÄʱ¼ä£¬²é×ÊÁϺͿ´ÊÓƵÍê³ÉµÄ£¬µ«ÎÒ¶Ôµ¥Ðк¯ÊýºÍ¶àÐк¯ÊýûÓÐ×ö¹ý¶àµÄÑо¿£¬ÒòΪÕß¿ÉÒÔ²éÎĵµ¡£»¹ÓоÍÊǶà±í²éѯÑо¿Ò²±È½Ïdz£¬Õâ¿ÉÒÔÔÚÒÔºóÓõ½µÄʱºòÔÚ¾ßÌåÑо¿¡£ »¹ÓоÍÊÇÒªÊìϤÊý¾Ý¿âµÄ²Ù×÷£¬Ôöɾ¸Ä²é£¬ÕâЩ¶¼ÒªÏ൱ÊìÁ·£¬Íü¼ÇʱҪ¼°Ê±¿´±Ê¼Ç¡£
SQL
1....... ......
Ò»¡¢É¾³ýÁÐ
ALTER TABLE AA DROP COLUMN DEP;
ÊÊÓÃÓÚС±í-----Êý¾ÝÁ¿Ð¡µÄʱºò£»
2¡¢ALTER TABLE AA SET UNUSED("DEP") CASCADE CONSTRAINTS;
È»ºóÔÚ¸ºÔØСµÄʱºò£¬É¾³ý
ALTER TABLE AA DROP UNUSED COLUMNS;
¶þ¡¢Ìí¼ÓÁÐ
ÏȼÓÒ»ÐÂ×Ö¶ÎÔÙ¸³Öµ£º
alter table table_name add mmm varchar2(10);
update ta ......