SQL Server DBCCÃüÁî
¡ô1.DBCC CacheStats £ºÏÔʾ´æÔÚÓÚµ±Ç° buffer Cache ÖеĶÔÏóµÄÐÅÏ¢£¬ÀýÈç £ºhitrates ±àÒëµÄ¶ÔÏóºÍÖ´Ðмƻ®
DBCC CACHESTATS
¡¡¡¡´ÓÕâ¸öÃüÁî¿ÉÒԵõ½Ò»Ð©¹Ø¼üµÄͳ¼ÆÐÅÏ¢£º
¡¡¡¡Hit Ratio£ºÏÔʾÌض¨¶ÔÏó¿ÉÒÔÔÚSql ServerµÄ»º´æÖб»ÃüÖеİٷֱȣ¬Õâ¸öÊýÖµÔ½´ó£¬Ô½ºÃ
¡¡¡¡Object Count£ºÏÔʾÌض¨ÀàÐ͵ĶÔÏóÔÚsql serverµÄ»º´æÖб»ÃüÖеÄ×ÜÊý
¡¡¡¡Avg.Cost:sql serverÓÃÓÚ²âÁ¿±àÒëÒ»¸öÖ´Ðмƻ®ËùÐèµÄʱ¼ä£¬ÒÔ¼°Õâ¸ö¼Æ»®ËùÐèµÄÄÚ´æ¡£¸ù¾ÝÕâ¸öÖµ£¬¿ÉÒÔ¾ö¶¨Ö´Ðмƻ®ÊÇ·ñÓ¦¸Ã¼ÓÔØÔÚ»º´æÖС£
¡¡¡¡Avg.Pages£º²âÁ¿ÔÚ»º´æÖеĶÔÏóʹÓÃ8KÒ³µÄƽ¾ù×ÜÊý
¡¡¡¡LW Ojbect Count£¬LW Avg Cost£¬WL Avg Stay£¬LW Ave Use£ºÕâЩÁеÄÖµ±íÃ÷ÓжàÉÙÌض¨µÄ¶ÔÏóÒѾ±»Ð´½ø½ø³Ì´Ó»º´æ×ÜÒÆ×ß¡£ÕâЩÊýÖµÔ½µÍ£¬Ô½ºÃ¡£
¡ô2.DBCC DROPCLEANBUFFERS£º´Ó»º³å³ØÖÐɾ³ýËùÓУ¬Çå³ý»º³åÇø¡£
ÔÚ½øÐвâÊÔʱ£¬Ê¹ÓÃÕâ¸öÃüÁî¿ÉÒÔ´Ósql server’sµÄÊý¾Ý»º´ædata catch(buffer)Çå³ýËùÓеIJâÊÔÊý¾Ý£¬ÒÔ±£Ö¤²âÊԵĹ«ÕýÐÔ¡£ÐèҪעÒâµÄÊÇÕâ¸öÃüÁîÖ»ÒÆ×߸ɾ»µÄ»º´æ£¬²»ÒÆ×ßÔ໺´æ¡£ÓÉÓÚÕâ¸öÔÒò£¬ÔÚÖ´ÐÐÕâ¸öÃüÁîÇ°£¬Ó¦¸ÃÏÈÖ´ÐÐCheckPoint£¬½«ËùÓÐÔàµÄ»º´æдÈë´ÅÅÌ£¬ÕâÑùÔÚÔËÐÐDBCC RROPCLEANBUFFERS ʱ£¬¿ÉÒÔ±£Ö¤ËùÓеÄÊý¾Ý»º´æ±»ÇåÀí£¬¶ø²»ÊÇÆäÖеÄÒ»²¿·Ö¡£
¡ô3.DBCC ErrorLog £ºÈç¹ûºÜÉÙÖØÆðmssqlserver·þÎñ£¬ÄÇô·þÎñÆ÷µÄÈÕÖ¾»áÔö³¤µÃºÜ¿ì£¬¶øÇÒ´ò¿ªºÍ²é¿´ÈÕÖ¾µÄËÙ¶ÈÒ²»áºÜÂý¡£Ê¹ÓÃÕâ¸öÃüÁ¿ÉÒԽضϵ±Ç°µÄ·þÎñÆ÷ÈÕÖ¾£¬Ö÷ÒªÊÇÉú³ÉÒ»¸öеÄÈÕÖ¾¡£¿ÉÒÔ¿¼ÂÇÉèÖÃÒ»¸öµ÷¶ÈÈÎÎñ£¬Ã¿ÖÜÖ´ÐÐÕâ¸öÃüÁî×Ô¶¯½Ø¶Ï·þÎñÆ÷ÈÕÖ¾¡£Ê¹Óô洢¹ý³Ìsp_cycle_errorlogÒ²¿ÉÒԴﵽͬÑùµÄÄ¿µÄ¡£
¡ô4.DBCC FLUSHPROCINDB:ÓÃÓÚÇåÀíÒ»¸öÊý¾Ý¿âʵÀýÖÐÖ¸¶¨Êý¾Ý¿âµÄ´æ´¢¹ý³ÌʹÓõĻº´æ¡£Êý¾Ý¿âµÄIDÊDZØÊä²ÎÊý
ÔÚ²âÊÔʱ±£Ö¤ÒÔÇ°µÄ´æ´¢¹ý³Ì¼Æ»®²»»á¶Ô²âÊÔ½á¹ûÔì³É¸ºÃæÓ°Ï죬¿ÉÒÔʹÓÃÕâ¸ö´æ´¢¹ý³Ì¡£
¡¡¡¡Àý£º
DECLARE @intDBID INTEGER SET @intDBID = (select dbid from master.dbo.sysdatabases where name = 'database_name')
DBCC FLUSHPROCINDB (@intDBID)
¡ô5.DBCC FREEPROCCACHE£ºÓÃÓÚÇåÀíËùÓÐÊý¾Ý¿âµÄ¹ý³Ì¸ßËÙ»º´æ¡£
ÀýÈ磬ÊͷŹý³Ì¸ßËÙ»º´æ½«µ¼ÖÂÖØбàÒëijЩ²¿·Ö(ÀýÈçÌرð SQL Óï¾ä)£¬¶ø²»ÊÇ´Ó¸ßËÙ»º´æÖжÔÆäÔÙʹÓÃ
Ïà¹ØÎĵµ£º
linq to sql ÔÚ²åÈëÖµµÄʱºò»¹ÊǺܷ½±ã¡£ÓÐʱºòÎÒÃÇÐèÒªÔÚ²åÈëÒ»¸öеÄʵÌåÖ®ºóµÃµ½ÄǸöʵÌåµÄÖ÷¼üIDµÄÖµ£¬Õâ¸öIDµ±È»±ØÐëÊÇ×ÔÔö¡£Ò»¶Îʱ¼äÎÒÒ»Ö±ÈÏΪֱ½ÓʹÓÃlinq to sqlµÄ²åÈë»úÖÆÊDz»¿ÉÒÔÔÚ×öµ½µÄ£¬ËùÒÔÖ»ÓÐʹÓô洢¹ý³ÌµÄ£¬¾ßÌå¿ÉÒԲ鿴ÕâƪÎÄÕ£ºhttp://blog.benhall.me.uk/2008/01/custom-insert-logic-with-linq-to- ......
²âÊÔ»útest°²×°µÄÊÇwindows server2008+sql server 2008£¬Êý¾Ý¿â°²×°³É¹¦¡£¿ÉÒÔÁ¬½Ó¾ÖÓòÍøÄÚÆäËû»úÆ÷µÄÊý¾Ý¿â£¨ÆäËû»úÆ÷µÄÊý¾Ý¿âΪSQL 2005£©¡£µ«ÊÇÍøÄÚÆäËû»úÆ÷·ÃÎÊtestʱ£¬ÎÞ·¨Á¬½Ó£¬±¨´í¡£ÐÅϢΪ£ºÔÚ½¨Á¢Óë·þÎñÆ÷µÄÁ¬½Óʱ³ö´í¡£ÔÚÁ¬½Óµ½SQL SERVER 2005ʱ£¬ÔÚĬÈϵÄÉèÖÃÏÂSQL SERVER ²»ÔÊÐí½øÐÐÔ¶³ÌÁ¬½Ó¿ÉÄܻᵼÖ´Îʧ°Ü ......
±¾ÎĽÚÑ¡×ÔMSDNµÄÎÄÕ¡¶ÎåÖÖÌá¸ß SQL ÐÔÄܵķ½·¨¡·£¬Ìá³öÈçºÎÌá¸ß»ùÓÚSQL ServerÓ¦ÓóÌÐòµÄÔËÐÐЧÂÊ£¬·Ç³£ÖµµÃÍƼö¡£¶ÔһЩTrafficºÜ¸ßµÄÓ¦ÓÃϵͳ¶øÑÔ£¬ÈçºÎÌá¸ßºÍ¸Ä½øSQLÖ¸ÁÊǷdz£ÖØÒªµÄ£¬Ò²ÊÇÒ»¸öºÜºÃµÄÍ»ÆƵ㡣
*ÎÄÕÂÖ÷Òª°üÀ¨ÈçÏÂһЩÄÚÈÝ£¨Èç¸ÐÐËȤ£¬ÇëÖ±½Ó·ÃÎÊÏÂÃæµÄURLÔĶÁÍêÕûµÄÖÐÓ¢ÎÄÎĵµ£©£º
1, ´Ó INSERT ·µ ......
(1)Êý¾Ý¼Ç¼ɸѡ£º
sql="select*fromÊý¾Ý±íwhere×Ö¶ÎÃû=×Ö¶ÎÖµorderby×Ö¶ÎÃû[desc]"
sql="select*fromÊý¾Ý±íwhere×Ö¶ÎÃûlike'%×Ö¶ÎÖµ%'orderby×Ö¶ÎÃû[desc]"
sql="selecttop10*fromÊý¾Ý±íwhere×Ö¶ÎÃûorderby×Ö¶ÎÃû[desc]"
sql="select*fromÊý¾Ý±íwhere×Ö¶ÎÃûin('Öµ1','Öµ2','Öµ3')"
sql="select*fromÊý¾Ý±íwhere× ......