Perform INSERT and Direct Performance Comparison of INSERT with Stored Procedures

xiaoxiao2021-03-06  40

Recently I write a program to import the list of IPs and the location of the location into the database. When you use the SQLCommand, you can use SQLCommand, and later I know that SQL Server can optimize the stored procedure, save the statement The analysis time is better than the INSERT statement directly. I put the INSERT statement in a temporary stored procedure, using this temporary stored procedure for INSERT operation, and roughly tested the time executed. The stored procedure is: Create Procedure # INSERTIPDATA @ Startip Nvarchar (50), @ Endip Nvarchar (50), @uestry nvarchar (50), @ local nvarchar (100) Asinsert INTO [ipwry] values ​​(@startip, @endip, @country @Local) Insert statement is: INSERT INTO [@Endip, @COUNTRY, @local) Execute this stored procedure to use SqlDataAdapter's Update, a total of 180,85 records. The result is as follows: The first second time the second time the third average direct implementation INSERT 133 seconds 132 seconds 135 seconds 133.3 seconds stored procedure 121 seconds 122 seconds 120 seconds 121 second test environment: Windows Server 2003, SQL Server 2000 (V8.0.818), Framework 1.1.4322 SP1 (WINFORM); Pentium 4 2.0GHz, 512MB RAM This results are described, and a large amount of INSERT statement in the stored procedure is about 10% higher than that of directly executing the INSERT statement.

转载请注明原文地址:https://www.9cbs.com/read-73829.html

New Post(0)