Alibabacloud.com offers a wide variety of articles about query optimization techniques in sql server, easily find your query optimization techniques in sql server information here online.
Yesterday's SQL Server query performance optimization-index creation principle (I) mainly introduced the principle. today are some of the main principles and checks the created indexes.
Iii. indexing principles
In general, building indexes depends on the data usage scenarios. In other words, which
Essential SQL query optimization techniques to speed up Website access and SQL access
In this article, I will introduce how to identify queries that cause performance problems, how to locate their problems, and how to quickly fix these problems and other methods to speed up
the size of the data in the table, if there is a lot of data in the table, count is the int type is problematic, so you need to return the default type (the value is usually the default type is big) to the int type. )
Summary: With SET SHOWPLAN_ALL on we can see what the SQL Server aggregation function does for this effect when it gives us the final effect.
2.3. Scalar aggregation
in the table, count is the int type is problematic, so you need to return the default type (the value is usually the default type is big) to the int type. )
Summary: With SET SHOWPLAN_ALL on we can see what the SQL Server aggregation function does for this effect when it gives us the final effect.
2.3. Scalar aggregation optimization
.24. If a temporary table is used, be sure to explicitly delete all temporary tables at the end of the stored procedure, TRUNCATE table first, and then drop table, which avoids longer locking of the system tables.25. Avoid using cursors as much as possible, because cursors are inefficient and should be considered for overwriting if the cursor is manipulating more than 10,000 rows of data.26. Before using a cursor-based method or temporal table method, you should first look for a set-based soluti
'the value of the Key5'
fromheadertable awhereA.headerid= 10000
SELECTA.*, t.a0001 as 'the value of the Key1', t.a0002 as 'the value of the Key2', t.a0003 as 'the value of the Key3', t.a0004 as 'the value of the Key4', t.a0005 as 'the value of the Key5'
fromHeadertable AInner Join
(SelectHeaderid, Detailkey, detailvalues fromdetailtable) T Pivot (MAX(detailvalues) forDetailkeyinch(a0001,a0002,a0003,a0004,a0005)) T onT.headerid=A.headeridwhereA.headerid= 10000
plans different? This is because ShipCountry contains a large number of duplicate values, with very few CustomerID duplicates, so the SQL Server system gives ShipCountry the hash aggregation pushed, and CustomerID pushes the stream aggregation. This means that the SQL Server system dynamically chooses the appropriate
numeric value) is converted to the int type when it is finally returned. )
Summary: On the SET SHOWPLAN_ALL on we can look at what the SQL Server aggregate function does for this effect when it gives us the final effect.
2.3. Scalar Aggregation Optimization Techniques:
Let's look at the difference between t
Original: Set STATISTICS io and set STATISTICS time in SQL Server query performance optimizationIn recent times, has been exploring the SQL Server query performance issues, of course, also aimless search for a lot of information,
block according to the pointer on the index block, so that the IO traffic is much less.
Second, index optimization technology
Is there an index that must be retrieved quickly? The answer is yes. Sometimes it's better to use indexes than to index faster. For example, we want to retrieve all the records in the above table, if not indexed, need access to 8,000 x1000 bytes/8k = 1000 pages, if you use the index, first retrieves the index, accesses 8,000 x
server| Speed | optimization
MS SQL Server Query optimization method (1) There are many reasons for the slow query speed, common as follows:
1, no index or no index (this is the most co
1. Use SET STATISTICS TIME ON
-- First clear the cache
Dbcc dropcleanbuffers;
Dbcc freeproccache;
-- Run
Set statistics time on;
SELECT orderid, custid, empid, shipperid, orderdate, filler
FROM dbo. Orders
WHERE orderdate> = '123'
AND orderdate
Set statistics time off;
GO
You will get a similar message:
SQL Server Analysis and Compilation Time:
CPU time = 15 ms, occupied time = 33 Ms.
Label: SQL Server Query optimization method The reasons for the slow query are many, the following are common 1, no index or no index (this is the most common problem of slow query, is the defect of program design)2, I/O throughpu
Many of my friends may be making mistakes in performance optimization as described below. If you have any need, please refer to the mistakes in SQL Server query performance optimization to get out of the index.
Many of my friends may be making mistakes in performance
name to run on any member server. The system operates as if each member server has a copy of the original table, but there is only one member table and one distributed partitioned view on each server. The location of the data is transparent to the application.11. Rebuild the index DBCC REINDEX, DBCC INDEXDEFRAG, shrink data and log DBCC SHRINKDB,DBCC shrinkfile.
data, the same query in different circumstances may produce the opposite result, how to apply well is mainly in our personal understanding and understanding, hope to see this article friends can deepen some understanding of the index and understanding , and get rid of the error of index and develop high performance application. I am not a DBA, just a common developer, the above are some of the actual work experience, experience, in view of my level i
high-performance applications.
I am not a DBA, but an ordinary developer. The above are some experiences and experiences in my practical work. In view of my very limited level, if you say something wrong or cannot understand it, I hope you can correct it to avoid misleading others. I am very grateful.
In the future, I will continue to write some practical experience on SQL Server
Tag: Style color IO using strong SP data on problemIn recent times, has been exploring the SQL Server query performance issues, of course, also aimless search for a lot of information, but also from the online great God's articles learned a lot, here, to the great God salute. It is by the great God selfless dedication of the influence of the spirit, so, the young
than the number of rows of data
The statements and data used in the example are used only as demos, the actual development application is more complex than the sample data, the same query in different circumstances may produce the opposite result, how to apply well is mainly in our personal understanding and understanding, hope to see this article friends can deepen some understanding of the index and understanding , and get rid of the error of in
(graphics and text), many things will be clear.
Summary:There may be a variety of SQL statements that implement the same query function. If you determine which optimization method you want to perform, if you only test it in time, it will be affected by many external factors. We understand how to execute MSSQL, i/O logic reading, querying the graph
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.