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

ʵÏÖSQL Server 2008Êý¾ÝѹËõ

ΪʲôÐèÒªÊý¾ÝѹËõ
¡¡¡¡Ê×ÏÈ¿ÉÄÜÐèÒªÌÖÂÛµÄÎÊÌâ¾ÍÊÇΪʲôÔÚ´æ´¢³É±¾²»¶Ï½µµÍµÄ½ñÌ죬΢Èí»¹ÒªÉ··Ñ¿àÐĵØÔÚSQL ServerÖÐʵÏÖ²¢ÇÒ²»¶Ï¸Ä½øÊý¾ÝѹËõ¼¼ÊõÄØ?
¡¡¡¡¾¡¹Ü´æ´¢³É±¾ÒѾ­²»ÔÙÊÇ´«Í³ÒâÒåÉϵÄÊ×Òª¿¼ÂÇÒòËØ£¬µ«ÊÇÕâ²¢²»´ú±íÊý¾Ý¿â³ß´ç²»ÊÇÒ»¸öÎÊÌ⣬ÒòΪÊý¾Ý¿â³ß´ç³ýÁË»áÓ°Ïìµ½´æ´¢³É±¾Ö®Í⣬»¹¼«´óµØ¹ØÁªµ½¹ÜÀí³É±¾ºÍÐÔÄÜÎÊÌâ¡£
¡¡¡¡Ê×ÏÈÎÒÃÇÀ´ÌÖÂÛΪʲô»áÓйÜÀí³É±¾µÄÎÊÌâ?ÒòΪÊý¾Ý¿âÐèÒª±¸·Ý£¬Êý¾Ý¿âµÄ³ß´çÔ½´ó£¬ÄÇô±¸·Ýʱ¼ä¾Í»áÔ½³¤£¬µ±È»ÁíÍâÒ»µã¾ÍÊÇÏûºÄµÄ±¸·ÝÓ²¼þ³É±¾Ò²»áËæÖ®Ìá¸ß(°üÀ¨ÐèÒªµÄ±¸·Ý½éÖʳɱ¾ºÍΪÁËÂú×㱸·Ý´°¿Ú¶øÐèÒª¸ü¸ß¼¶µÄ±¸·ÝÉ豸´øÀ´µÄ²É¹º³É±¾)£¬»¹ÓÐÒ»ÖÖ¹ÜÀí³É±¾¾ÍÊÇÊý¾Ý¿âµÄά»¤³É±¾£¬ÀýÈçÎÒÃǾ­³£ÐèÒªÍê³ÉµÄDBCCÈÎÎñ£¬Êý¾Ý¿â³ß´çÔ½´ó£¬ÎÒÃǾÍÐèÒª¸ü¶àµÄʱ¼äÀ´Íê³ÉÕâЩÈÎÎñ¡£
¡¡¡¡½Ó×ÅÎÒÃÇÔÙ¿´¿´ÐÔÄÜÎÊÌâ¡£SQL ServerÔÚɨÃè´ÅÅ̶ÁÈ¡Êý¾ÝµÄʱºò¶¼ÊÇ°´ÕÕÊý¾ÝҳΪµ¥Î»½øÐжÁÈ¡µÄ£¬Òò´ËÈç¹ûÒ»ÕÅÊý¾ÝÒ³Öаüº¬µÄÊý¾ÝÐÐÊýÔ½¶à£¬SQL ServerÔÚÒ»´ÎÊý¾ÝÒ³IOÖлñµÃµÄÊý¾Ý¾Í»áÔ½¶à£¬ÕâÑùÒ²¾Í´øÀ´ÁËÐÔÄܵÄÌáÉý¡£
¡¡¡¡×îºó¿¼ÂÇ´æ´¢µÄ³É±¾£¬°´ÕÕÔ­ÏÈSQL Server 2005 SP2ÖÐvardecimalµÄѹËõÊý¾ÝΪÀý£¬30%µÄ¿Õ¼ä½ÚÊ¡Ò²¾ÍÒâζ×Å30%µÄ´æ´¢³É±¾£¬¶ø°´ÕÕSQL Server 2008µ±Ç°·Å³öµÄ²âÊÔÊý¾Ý£¬²ÉÓÃеÄÊý¾ÝѹËõ¼¼Êõ¿ÉÒÔ´ïµ½2X-7XµÄ´æ´¢ÂÊ£¬ÔÙ¼ÓÉÏÈç¹ûÆóÒµÒª¿¼ÂÇÈÝÔÖ¶øÔö¼ÓµÄ´æ´¢¿Õ¼ä£¬ÕâÑù½ÚÊ¡µÄ´æ´¢Ó²¼þ³É±¾Ò²½«ÊÇÏëµ±¿É¹ÛµÄ¡£
¡¡¡¡SQL Server 2005 SP2ΪÎÒÃÇ´øÀ´ÁËvardecimal¹¦ÄÜ£¬ÕâÏÄÜʹµÃÔ­À´¶¨³¤µÄdecimalÊý¾ÝÔÚÊý¾ÝÎļþÖÐÒԿɱ䳤µÄ¸ñʽ´æ´¢£¬¾Ý³ÆÕâÏÄÜ¿ÉÒÔΪµäÐ͵ÄÊý¾Ý²Ö¿â½ÚÊ¡30%µÄ¿Õ¼ä£¬¶øSQL Server 2008ÔÚÕâÒ»»ù´¡ÉÏÓÖ½øÒ»²½ÔöÇ¿ÁËÊý¾ÝѹËõ¹¦ÄÜ¡£SQL Server 2008ÏÖÔÚÖ§³ÖÐÐѹËõºÍÒ³ÃæѹËõÁ½ÖÖÑ¡ÏÊý¾ÝѹËõÑ¡Ïî¿ÉÒÔÔÚÒÔ϶ÔÏóÉÏÆôÓãº
¡¡¡¡Î´´´½¨¾Û´ØË÷ÒýµÄ±í
¡¡¡¡´´½¨¾Û´ØË÷ÒýµÄ±í
¡¡¡¡·Ç¾Û´ØË÷Òý(¶Ô±íÉèÖÃѹËõÑ¡Ïî²»»áÓ°Ïìµ½¸Ã±íÉϵķǾ۴ØË÷Òý£¬Òò´Ë¾Û´ØË÷ÒýµÄѹËõÐèÒªµ¥¶ÀÉèÖÃ)
¡¡¡¡Ë÷ÒýÊÓͼ
¡¡¡¡·ÖÇø±íºÍ·ÖÇøË÷ÒýÖеĵ¥¸ö·ÖÇø
¡¡¡¡ÈçºÎʹÓÃÊý¾ÝѹËõ
¡¡¡¡SQL Server 2008ÖеÄѹËõÑ¡Ïî¿ÉÒÔÔÚ´´½¨±í»òË÷Òýʱͨ¹ýOption½øÐÐÉèÖã¬ÀýÈ磺
CREATE TABLE TestTable (col1 int, col2 varchar(200)) WITH (DATA_COMPRESSION = ROW);
¡¡¡¡Èç¹ûÐèÒª¸Ä±äÒ»¸ö·ÖÇøµÄѹËõÑ¡ÏÔò¿ÉÒÔÓÃÒÔÏÂÓï¾ä£º
ALTER TABLE TestTable REBUILD PARTITION = 1 WITH (DATA COMPRESSION = PAGE);
¡¡¡¡Èç¹ûÐèҪΪ·ÖÇø±íµÄ¸÷¸ö·ÖÇ


Ïà¹ØÎĵµ£º

¸ßЧSQL²éѯ֮Ë÷Òý¸²¸Ç(index coverage)

½ñÌì×öSQL ÓÅ»¯£¬²éÕÒÖ´Ðмƻ®Ê±£¬Ö´Ðмƻ®£¬·¢ÏÖ´ËÖ´Ðмƻ®ÓëÒÔÍùµÄ¼Æ»®ÓÐËùÇø±ð£»ÕÒ¼»¥ÁªÍø£¬ÖÕÓÚÕÒһƪÓйØÑо¿±È½ÏÉîÈëµÄÎÄÕ£»
Ô­Ö´Ðмƻ®Ê¹ÓõÄÊÇË÷ÒýɨÃ裬ͻȻһÏ»áʹÓÃË÷Òý¸²¸Ç¼¼Êõ£¬Ð§ÂÊ´óÔö£»
SELECT * µÄÕæÏࣺË÷Òý¸²¸Ç(index coverage)
SELECT *µÄЧÂʺÜÔã¸âÂ𣿵±È»£¬ËùÓÐÈ˶¼ÖªµÀÕâÒ»µã£¬µ«ÊÇΪʲô ......

¸ßЧSQL²éѯ֮Ë÷Òý£¨V£©

ÏÈÕ¾ÔÚÓ¦ÓóÌÐòµÄ½Ç¶È˵˵ËüÃǵIJ»Í¬¡£
1¡¢ Ö±½ÓÆ´ SQL
¾ÍÏñ´ó¼ÒÁ˽âµÄÄÇÑù£¬Ö±½ÓÆ´ SQL ´øÀ´ÁË SQL ×¢Èë¹¥»÷£¬´øÀ´ÁËƴʱЩÐíµÄÐÔÄÜËðʧ£¬µ«ÊÇÆ´²»ÓÃÌí¼Ó SqlParameter £¬»áÉÙдºÜ¶à´úÂë——ºÜ¶àÈËϲ»¶Ö±½ÓÆ´£¬Ò²Ðí¾ÍÒòΪÕâµã¡£ÕâÖÖ×ö·¨»á°ÑÄãÆ´ºÃµÄ SQL Ô­ÑùÖ±½Ó·¢Ë͵½ DB ·þÎñÆ÷È¥Ö´ÐС££¨×¢ÒâÀàËÆ &rdquo ......

¸ßЧSQL²éѯ֮Ë÷Òý£¨II£©

ÉÏ»ØÎÒÃÇ˵µ½ÆÀ¹ÀÒ»ÌõÓï¾äÖ´ÐÐЧÂÊÖ÷Òª¿´Âß¼­ IO £¨É¶ÊÇÂß¼­ IO £¬É¶ÊÇÎïÀí IO ¼ûÁª»úÎĵµ£©£¬Õâ´ÎÎÒÃǼÌÐø¡£
ÎÒÃÇÏÈ˵˵£¬·µ»Ø¶àÐнá¹ûʱ£¬ÎªÊ²Ã´ SQLServer ÓÐʱ»áÑ¡Ôñ index seek £¬ÓÐʱ»áÑ¡Ôñ index scan ¡£
ÒÔ nonclustered index ΪÀý˵Ã÷¡£
ÏñËùÓеÄË÷Òý B Ê÷Ò»Ñù£¬·Ç¾Û¼¯Ë÷ÒýÊ÷Ò²°üÀ¨ÍêÈ«ÓÉË÷ÒýÊý¾Ý×é³ÉµÄ¸ù½ ......

SQL²é±íÃû¡¢×Ö¶ÎÃû¡¢±í˵Ã÷¡¢×Ö¶Î˵Ã÷

SQL ²é¿´ËùÓбíÃû£º
select name from sysobjects where type='U'
²éѯ±íµÄËùÓÐ×Ö¶ÎÃû£º
Select name from syscolumns Where ID=OBJECT_ID('±íÃû')
select * from information_schema.tables
select * from information_schema.views
select * from information_schema.columns
ACCESS
²é¿´ËùÓбíÃû£º
se ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ