Create statistics to Optimize Query Performance

Source: Internet
Author: User

When I use the "database engine optimization consultant" of sqlserver2008 to optimize an SQL statement today, the following suggestions are provided in the index recommendations:
-- Create statistics
Create statistics [_ dta_stat_1758629308_16_10_1] on [DBO]. [prmorderpromisetime] ([distributionid], [storeid], [orderid])

-- Include Index
Create nonclustered index [_ dta_index_prmordersiteactualtime_6_1582628681 _ k1_2_7] on [DBO]. [prmordersiteactualtime]
(
[Orderid] ASC
)
Include ([siteid],
[Actualsiteid]) with (sort_in_tempdb = OFF, ignore_dup_key = OFF, drop_existing = OFF, online = OFF) on [primary]

Especially create statistics. The following knowledge comes from csdn:

1. statistics is the statistical information of several columns in a table. For example, if a table is the score of a certain test for all students, the score column type is int and the value range is an integer ranging from 0 to 100, then statistc is the number of people each score has. In a specific query, using an index may speed up or slow down. Therefore, SQL Server must make a prediction on the effect of using the index in advance. The prediction is based on statistics.
2. By default, when the table or index is changed, the statistics are automatically updated accordingly to keep the statistics updated. However, you can disable the automatic update function in the database option to speed up data table updates. However, statistics must be updated manually on a regular basis. Because the expired statistical information may lead to misjudgment on whether to use the index. No difference was found between SQL2000 and sql2005.
3. indexes must rely on the correct statistics to play a role. Your sql2005 optimization tool automatically generates creation statements for columns without statistic.

 

On msdn for help http://msdn.microsoft.com/zh-cn/library/ms188038 (SQL .105). aspx, http://msdn.microsoft.com/zh-cn/library/bb510669.aspx

There are too many things to learn about SQL, so you need to continue learning with patience in the future.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.