MACHINE: CPU: 2 GB memory: 2 GB Database: SQL 2005 depends on the machine configuration, the results will be different.
Performance Test Description:
1. query after the database server is restarted. That is, the result of the first query.
2. Compare the database query performance.
Test conditions:
1. Use temporary tables during storage: (proc1) Select Top 1000 *
Into # T1
From somastinsert into # t1select Top 100 * From somast
Select * from # T1
--- Delete table data
Truncate table # T1
-- Delete a temporary table
Drop table # T1 execution time: 1039 Ms
2. Use Union all: (proc2) Select Top 1000 * From somast In the Stored Procedure
Union all
Select Top 100 * From somast execution time is 5017 Ms
Note:
After the preceding two stored procedures are executed once, the preceding two stored procedures are executed again, and the execution time changes substantially.
Stored Procedure proc1, the execution time is 728 Ms
Stored Procedure proc2, with execution time of 998 Ms
However, in practice, although in a short period of time, it is unlikely that the same person will query the same stored procedure twice or more. in most cases, they are executed by different people at different times.
In addition, the optimization of the stored procedure will shorten the execution time after optimization. If optimization can be performed, optimization should be performed.