Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚSQL Server tempdbÂúʱ¼ì²éÊý¾ÝÎļþ

×÷ΪһÃûÊý¾Ý¿âDBA£¬¿Ï¶¨»áÌý˵¹ý“tempdbÊý¾Ý¿âÂúÁË”¡£Í¨³£ÎÒÃǺÜÈÝÒ×È·¶¨Ôì³ÉÕâÒ»ÎÊÌâµÄÔ­Òò¡£µ«ÊǸü¶àµÄʱºòÕâÒ»ÎÊÌâÖ÷ÒªÔ´ÓÚÒ»×éÇëÇó£¬Éæ¼°µ½Ð´úÂ벿Êð»òÖð½¥Ôö¼ÓµÄÊý¾Ý¡£
¡¡¡¡“TempdbÂúÁË”Òâζ×Åʲô?
¡¡¡¡µ±SQL Server tempdbÂúÁËʱ£¬Éϲã¹ÜÀí³£³£ÐèÒª¾ö²ß¡¢Ò»Ð©¿ª·¢ÈËÔ±¿ÉÄÜ»áÍÆжÔðÈΣ¬¾ÍÁ¬¸ß¼¶DBAÒ²º¦ÅÂÅöµ½ÕâÖÖÇé¿ö¡£
¡¡¡¡ºÍÎÒ¸æËß¹ÜÀíÔ±µÄÒ»Ñù£¬Ê×ÏȾ­ÑéµÄ×ö·¨¾ÍÊÇ£º±£³ÖÀä¾²¡£²»ÒªÈû¹Ã»Óй«²¼µÄÇé¿ö¸øÆäËû·½ÃæÔì³ÉѹÁ¦£¬ÄÇÑù¿ÉÄÜÄð³É¸ü´óµÄ´íÎó¡£
¡¡¡¡¼ÈÈ»Çé¿öÒѾ­³öÏÖÁË£¬ÄÇÎÒÃǾÍÀ´½â¾öÎÊÌâ¡£TempdbÊý¾Ý¿âÓÉÁ½²¿·Ö×é³É£ºÒ»ÊÇԭʼÎļþ×éÀïµÄÊý¾ÝÎļþ£¬¶þÊÇtempdbÈÕÖ¾Îļþ¡£ÕâÁ½Õ߶¼¿ÉÄܳö´í£¬µ«´íÎóÐÅÏ¢»á¸æËßÄãÄÄÒ»²¿·ÖÂúÁË¡£Ê×ÏÈÎÒÃÇÒ»Æð¿´¿´Êý¾ÝÎļþ²¿·Ö¡£ÔÚÒÔºóµÄÎÄÕ²¿·ÖÖÐÔÙ½²½âÈÕÖ¾Îļþ¡£
¡¡¡¡ÎÒÃÇÔõôѹËõÔ´Îļþ?
¡¡¡¡Ê×ÏÈÎÒÃÇÒªÁ˽âÒ»ÏÂÈ·¶¨ÊÇʲôռÓô󲿷ֿռäµÄ·½·¨£¬ÄÄÒ»¸ö·þÎñÆ÷ÓÐÎÒÃÇ´¦ÀíµÄIDºÅ(SPID)¡¢ÇëÇóÊÇ´ÓÄÄһ̨Ö÷»úÉÏ·¢³öµÄ¡£ÒÔϲéѯ½«·µ»ØÊý¾Ý¿âÀïÕ¼¿Õ¼äµÄÇ°1000¸öSPID¡£¼ÇסÕâЩ·µ»ØµÄֵΪҳÂëÊý¡£Îª´Ë£¬ÎÒËãÁËһϴ洢ֵ(µ¥Î»ÎªMB)¡£Í¬Ñù£¬ÎÒÃÇ»¹Òª×¢Òâ¼ÆÊýÆ÷ÊÇËæ×ÅSPIDµÄʹÓÃʱ¼ä¶øÖð½¥»ýÀ۵ģº
¡¡¡¡SELECT top 1000
¡¡¡¡s.host_name, su.[session_id], d.name [DBName], su.[database_id],
¡¡¡¡su.[user_objects_alloc_page_count] [Usr_Pg_Alloc], su.[user_objects_dealloc_page_count] [Usr_Pg_DeAlloc],
¡¡¡¡su.[internal_objects_alloc_page_count] [Int_Pg_Alloc], su.[internal_objects_dealloc_page_count] [Int_Pg_DeAlloc],
¡¡¡¡(su.[user_objects_alloc_page_count]*1.0/128) [Usr_Alloc_MB], (su.[user_objects_dealloc_page_count]*1.0/128)
¡¡¡¡[Usr_DeAlloc_MB],
¡¡¡¡(su.[internal_objects_alloc_page_count]*1.0/128) [Int_Alloc_MB], (su.[inte
¡¡¡¡rnal_objects_dealloc_page_count]*1.0/128)
¡¡¡¡[Int_DeAlloc_MB]
¡¡¡¡from [sys].[dm_db_session_space_usage] su
¡¡¡¡inner join sys.databases d on su.database_id = d.database_id
¡¡¡¡inner join sys.dm_exec_sessions s on su.session_id = s.session_id
¡¡¡¡where (su.user_objects_alloc_page_count > 0 or
¡¡¡¡su.internal_objects_alloc_page_count > 0)
¡¡¡¡order by case when su.user_objects_alloc_page_count > su.internal_objects_
¡¡¡¡alloc_page_count then


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

Ìá¸ßÊý¾Ý¿âSQLÓï¾ä²éѯËٶȵļ¸¸ö·½·¨£¨×ª£©


Ìá¸ßÊý¾Ý¿âSQLÓï¾ä²éѯËٶȵļ¸¸ö·½·¨
1¡¢³ÌÐòÖУ¬
±£Ö¤ÔÚʵÏÖ¹¦ÄܵĻù´¡ÉÏ£¬¾¡Á¿¼õÉÙ¶ÔÊý¾Ý¿âµÄ·ÃÎÊ´ÎÊý£»
ͨ¹ýËÑË÷²ÎÊý£¬¾¡Á¿¼õÉÙ¶Ô±íµÄ·ÃÎÊÐÐÊý,×îС»¯½á¹û¼¯£¬´Ó¶ø¼õÇáÍøÂ縺µ££»
Äܹ»·Ö¿ªµÄ²Ù×÷¾¡Á¿·Ö¿ª´¦Àí£¬Ìá¸ßÿ´ÎµÄÏìÓ¦Ëٶȣ»
ÔÚÊý¾Ý´°¿ÚʹÓÃSQLʱ£¬¾¡Á¿°ÑʹÓõÄË÷Òý·ÅÔÚÑ¡ÔñµÄÊ×ÁУ»
Ëã·¨µÄ½á¹¹¾¡Á¿¼òµ¥ ......

Oracle SQL_TRACEʹÓÃС½á

Ò»¡¢¹ØÓÚ»ù´¡±í
Oc_COJ^c680758
rd-A6z\&[1R1] H680758
Oracle
10G֮ǰ£¬ÆôÓÃAUTOTRACE¹¦ÄÜÐèÒªÊÖ¹¤´´½¨plan_table±í£¬´´½¨½Å±¾Îª$ORACLE_HOME/rdbms/admin
/utlxplan.sql¡£µ«ÔÚ10gÖУ¬ÒѾ­Ä¬ÈÏ´´½¨ÁËPLAN_TABLE$µÄ»ù±í£¬²¢ÒÔpublicÓû§´´½¨ÁËÏàÓ¦µÄͬÒå´ÊPUBLIC¡£ITPUB¸öÈË¿Õ¼äDR#IlHrT
ITPUB¸ ......

SQL Server 2005 Á¬½Ó×Ö·û´®´úÂë


SQL Native Client ODBC Driver
±ê×¼°²È«Á¬½Ó
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
ÄúÊÇ·ñÔÚʹÓÃSQL Server 2005 Express ÇëÔÚ“Server”Ñ¡ÏîʹÓÃÁ¬½Ó±í´ïʽ“Ö÷»úÃû³Æ\SQLEXPRESS”¡£
ÊÜÐŵÄÁ¬½Ó
Driver={SQL Native ......

ʹÓÃSQL ServerµÄOPENROWSETº¯Êý

¡¡Äã¿ÉÄܳ£³£»áÐèÒªÔËÐÐÒ»¸öad hoc²éѯ´ÓÔ¶³ÌOLE DBÊý¾ÝÔ´ÌáÈ¡Êý¾Ý£¬»òÕßÅúÁ¿ÏòSQL Server±íµ¼ÈëÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬Äã¿ÉÒÔÔÚT-SQL(Transact-SQL£¬Î¢Èí¶ÔSQLµÄÀ©Õ¹)ÖÐÓÃOPENROWSETº¯Êý¸øÊý¾ÝÔ´´«ÈëÒ»¸öÁ¬½Ó´®ºÍ²éѯÀ´ÌáÈ¡ÐèÒªµÄÊý¾Ý¡£
¡¡¡¡Äã¿ÉÄܳ£³£»áÐèÒªÔËÐÐÒ»¸öad hoc²éѯ´ÓÔ¶³ÌOLE DBÊý¾ÝÔ´ÌáÈ¡Êý¾Ý£¬»òÕßÅúÁ¿ÏòSQL ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ