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µÄÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾äÁË£º
SQL³õѧÕß¡£
¾³£Íü¼Ç³£ÓõÄDML»òÊÇDDL SQL Óï¾ä¡£
ÔÚ¶àÈË¿ª·¢Î¬»¤µÄSQLÖУ¬Ã¿¸öÈ˶¼ÓÐ×Ô¼ºµÄSQLÏ°¹ß£¬Ã»ÓÐÒ»Ì×ͳһµÄ¹æ·¶¡£
ÔÚSQL Server Management StudioÖУ¬ÒѾ¸ø´ó¼ÒÌṩÁ˺ܶೣÓõÄÏÖ³ÉSQL¹æ·¶Ä£°å¡£
SQL Server Management ......
Ò»£ºSQL Loader µÄÌصã
oracle×Ô¼º´øÁ˺ܶàµÄ¹¤¾ß¿ÉÒÔÓÃÀ´½øÐÐÊý¾ÝµÄǨÒÆ¡¢±¸·ÝºÍ»Ö¸´µÈ¹¤×÷¡£µ«ÊÇÿ¸ö¹¤¾ß¶¼ÓÐ×Ô¼ºµÄÌص㡣
±ÈÈç˵expºÍimp¿ÉÒÔ¶ÔÊý¾Ý¿âÖеÄÊý¾Ý½øÐе¼³öºÍµ¼³öµÄ¹¤×÷£¬ÊÇÒ»ÖֺܺõÄÊý¾Ý¿â±¸·ÝºÍ»Ö¸´µÄ¹¤¾ß£¬Òò´ËÖ÷ÒªÓÃÔÚÊý¾Ý¿âµÄÈȱ¸·ÝºÍ»Ö¸´·½Ãæ¡£ÓÐ×ÅËٶȿ죬ʹÓüòµ¥£¬¿ì½ÝµÄÓŵ㣻ͬʱҲÓÐһЩȱµ ......
Select * into customers from clients
(Êǽ«clients±íÀïµÄ¼Ç¼²åÈëµ½customersÖУ¬ÒªÇó£ºcustomers±í²»´æÔÚ£¬ÒòΪÔÚ²åÈëʱ»á×Ô¶¯´´½¨Ëü£»)
Insert into customers select * from clients
½â£ºInsert into customers select * from clients£©ÒªÇóÄ¿±ê±í£¨customers£©´æÔÚ£¬
ÓÉÓÚÄ¿±ê±íÒѾ´æÔÚ£¬ËùÒÔÎÒÃdzýÁ˲åÈëÔ´±í£ ......
select a.FRMNO,a.GATE,a.MSGID,a.MailSendTime,a.UserNM, a.MailSubject,a.IsRead,a.FRMID,a.isattach,b.STATE ,a.FLOWSTATE from ROAMSGE a, ROASTAT b where a.FRMID = b.FRMID and b.state='1' and a.FrmNm like '%" + Cdorpsel1 + "%' and a.MAILSENDTIME>to_date('" + date1 + "','YYYY-MM-DD') ......