Dari MS SQL City, ada beberapa tips menarik (sebagian belum diterjemahkan) mengenai optimisasi sql server.
- Gunakan SP sebagai alternatif kueri yang berat.
- Gunakan SET NOCOUNT ON untuk menghindari munculnya pesan jumlah data yang terpengaruh.
- Gunakan nama terkualifikasi lengkapnya: server.db.owner.object untuk memberikan kesempatan server menggunakan ulang rencana eksekusinya.
- Gunakan nilai keluaran integer untuk apapun untuk menghindari pembuatan recordset.
- Don’t use the prefix “sp_” in the stored procedure name if you need to create a stored procedure to run in a database other than the master database.
- Use the sp_executesql stored procedure instead of the EXECUTE statement.
- Use sp_executesql stored procedure instead of temporary stored procedures.
- If you have a very large stored procedure, try to break down this stored procedure into several sub-procedures, and call them from a controlling stored procedure.
- Try to avoid using temporary tables inside your stored procedure.
- Try to avoid using DDL (Data Definition Language) statements inside your stored procedure.
- Add the WITH RECOMPILE option to the CREATE PROCEDURE statement if you know that your query will vary each time it is run from the stored procedure.
- Use SQL Server Profiler to determine which stored procedures has been recompiled too often.