Read about sql stored procedure performance tuning, The latest news, videos, and discussion topics about sql stored procedure performance tuning from alibabacloud.com
SQL Server focuses on optimization of Stored Procedure performance, data compression, and page compression to improve IO performance (I ).
Preface
The SQL Server basic series is not over yet, And the last point is not written, and
stored, the maximum value and the pointer to the next primary leaf level block, or a non-leaf level block (pointer), where the pointer is the file number + block number of the block. In the B*tree block of Oracle, the key value of the indexed column is stored +rowid (the file number + block number + slot number of the data row) so that the data rows in the table can easily be found through the index by the
When software development uses Microsoft sql2005 to store data, there are multiple methods to retrieve information. There are dynamically generated SQL statements and stored procedures. But is their performance the same?
Download the test program and source code
Test Description:
The purpose of this test is to compare whether the execution time of dynamic
@timediff datetimebeginsetnocounton;select@timediff=getdate()selectNBSP; * NBSP; from NBSP; ( Select NBSP; *,row_number () over (order NBSP; by NBSP; ID ASC NBSP; as Idrank NBSP; from NBSP; tb_ testtable) NBSP; as idwithrownumber NBSP; where idrank> @pageSize * @pageIndex and idrank selectdatediff(ms,@timediff,getdate())as耗时setnocount off;end---5、利用临时表及Row_numbercreate procedure proc_CTE --利用临时表及Row_number(@pageIn
millisecondsPage5: 3 seconds 421 MsPage6: 3 seconds 515 MsUse ROW_NUMBER () for statistics only on the first page:Page1: 2 seconds 937 millisecondsPage2: 0 seconds 218 millisecondsPage3: 0 seconds 359 millisecondsPage4: 0 seconds 468 millisecondsPage5: 0 seconds 578 millisecondsPage6: 0 seconds 687 millisecondsConclusion: In the stored procedure, if the total number of records is counted each time, the eff
Tags: and fast speaking tuning market buffer way a completely"High-performance SQL Tuning essentials and Case Resolution" a book has been launched, many enthusiastic readers on the contents of the book and some of the specific questions raised questions, because of the numerous readers plus my daily work busy, here on
of pages as SET NOCOUNT on IF ISNULL (@TotalCount, ') = ' Set @TotalCount = 0 Set @Order = RTRIM ( LTRIM (@Order)) Set @PrimaryKey = RTRIM (LTRIM (@PrimaryKey)) Set @FieldList = REPLACE (RtriM (LTRIM (@FieldList)), ', ') while CHARINDEX (', ', @Order) > 0 OR CHARINDEX (', ', @Order) > 0 BEGIN SET @Orde R = Replace (@Order, ', ', ', ') SET @Order = replace (@Order, ', ', ', ') END IF ISNULL (@TableName, ') = ' OR ISNULL (@F Ieldlist, ') = ' or ISNULL (@PrimaryKey, ') = ' or @SortType Call Metho
1. Create Database Liezui_Test
ID int primary key auto-Increment
Title varchar (100)
ReadNum int
2. Insert 1 million data records into the databaseDeclare @ I int
Set @ I = 1
While I Begin
Insert into Liezui_Test (Title, ReadNum) values ('total execution statistics', @ I)
Set @ I = @ I + 1
End
GO
Declare @ I int
Set @ I = 1
While I Begin
Insert into Liezui_Test (Title, ReadNum) values ('towels are prone to harmful bacteria because they are often wet. ', @ I)
Set @ I = @ I + 1
End
GO
3. added
1. Create Database Liezui_Test ID int primary key auto-IncrementTitle varchar (100)ReadNum int2. Insert 1 million data records into the databaseDeclare @ I intSet @ I = 1While I BeginInsert into Liezui_Test (Title, ReadNum) values ('total execution statistics', @ I)Set @ I = @ I + 1EndGODeclare @ I intSet @ I = 1While I BeginInsert into Liezui_Test (Title, ReadNum) values ('towels are prone to harmful bacteria because they are often wet. ', @ I)Set @ I = @ I + 1EndGO3. added the SelectByTitle
In SQL Server database operations, we often use stored procedures to implement the query data paging to facilitate the browsing of the viewer.
To create a database data_test:
Create DATABASE data_test go use
data_test go create table
tb_testtable --Creating Tables
(
ID int Identity (1,1) primary key,
userName nvarchar not null,
userpwd nvarchar (.) not NULL,
UserEmail nvarchar () nul
SQL database Stored Procedure example parsing and SQL stored procedure example
What is a stored procedure:Stored procedures can be said to be a record set, it is a code block composed o
the Set TRACE function in Sqlplus analysis of performance and index usage of statements by toad or PL/SQL developer not satisfied with Oracle default optimizations you can force the use of hint, but it is generally not recommended It is generally not recommended to index a field that stores only or no information for flag. You can use bitmap indexing if necessary * There is a recursive query situation
increase the simultaneous processing capacity
Determine earnings
Determine cost
Monitoring tasks with common bottlenecks
Monitor memory usage
Monitor thread and CPU usage
Monitor hard disk I/O
Monitor low-performance queries
Monitor stored procedures, SQL, and user activities
Monitor current locks and user interactions
Create a
SQL Server Stored Procedure creation and modification implementation code, SQL Server Stored Procedure
Open the management tool of SQL Server 2005, select the database for which you wan
:16TAB1 small, TAB2 billion level above, two weeks data in tens of millions of.Lan Hua Main 16:13:22Ok.Orchid Island Main 16:16:29So change the SQL:with T1 as (Select count (t.c1), t.c1,t.c2,t.c3,t.c4,t.c5From Tab1 twhere T.c2 not in (' Val1 ', ' val2 ', ' val3 ', ' val4 ', ' VAL5 ')and C1 is not NULLGroup by T.C1, T.C2,T.C3,T.C4,T.C5)Select T1.c1,t1.c2,t1.c3,t1.c4,t1.c5from T1Where NOT EXISTS (Select/*+ Use_hash (m,n) */M.C1, M.C2,M.C3,M.C4,M.C5from T1 m,tab2 Nwhere N.c2 > Sysdate-14and m.c1 =
MySql stored procedure-1. Basic knowledge of SQL stored procedure before understanding MySq, let's take a look at some simple questions.Q: What is a stored procedure? (
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.