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.