I am executing some script which will create a database with some table, SP and data. In my one PC(Windows 7, SQL SREVER R2) it takes 33 second to complete and in another PC(Server 2008, SQL SERVER R2) it takes nearly 20 minutes. Can someone tell me what will be issue?
1 回答
Assuming the script and the data inserted is 100% identical, then you probably should look out for environmental changes that might cause the problems. Those are the things i'd check:
- Is there CPU or memory difference in the prod server you're deploying on? if it has bad hardware then it might cause problems (for example, cheap VM on Windows Azure or EC2 would probably get worst performance than your dev computer, if you don't get enough CPU cycles). Are the overall performance good?
- Maybe there is an I/O problem in the prod server you're deploying to. Try using sqlio to benchmark the server and your dev machine (read here for instructions: http://www.mssqltips.com/sqlservertip/2127/benchmarking-sql-server-io-with-sqlio/) I/O is very important thing while dealing with databases. BTW, how big is your DB? how much data are we talking about?
If it's not hardware problem (1 or 2), then you might look for configuration issues. There are many possible configuration problems, but some of them are more likely than the others:
3.1 Make sure your data and log files are in separated volumes, and you use a RAID level that good for what you're doing. RAID 10 is probably the best, but it's pricey. but, RAID 5 would cause, for example, decreasing in write performance.
3.2 If you're creating the database for the first time, then you're probably allocating the data files and the log files. depending on the size of the files you're creating, it might be really heavy IO operation, unless you grant in the group policy to the sql server the permission called "Perform Volume Maintenance Tasks, which won't cause 0-ing the entire size
3.3 Make sure you're using the same recovery model in the prod and in the dev machine. If you're using "Full" or "Bulk Logged" recovery model, and insert a lot of data, the size of the log file will grow. make sure you pre-allocate most of the size at advance and not causing multiple small auto-growth that could really affect performance.
If none of the above helped, try and give more information, including full hardware specification of the target server, the storage, the LUN's configuration and every change you did from the default sql server installation configuration.
Best of luck.