SQL Server Performance Tuning
QuestionBeing a developer, I am not an expert at SQL Server (I know just enough to get done what I need); however, many of our clients are asking us for growth estimations of our database. How much MBs/GBs will a database take up? Also, does SQL Server have the ability to estimate how big it […]
My application makes heavy use of temp tables. Should I be creating temp tables as needed, or should I be using a permanent table over and over instead?
Assuming everything is the same, both tables will produce very similar access speeds. If your application makes heavy use of temp tables, you might consider using a permanent table for these reasons: A regular table already exists. A temp table has to be created, which takes time and overhead. For example, if you need to […]
I don’t know how to transfer an array to a table, and I even if I can, I don’t know if it will be any faster than using INSERT INTO?
Question I have an INSERT INTO SELECT query which appends about 500,000 rows of data to a table. The query takes about 22 minutes to run. I would like it to run in less than 5 minutes, if possible. One solution I thought of was to append the 500,000 rows of data to an array […]
Question The following two queries produce the same results. Is one or the other versions of these two queries more efficient than the other? SELECT DISTINCT productcode FROM sales SELECT productcode FROM sales GROUP BY productcode Answer The goal of both of the above queries is to produce a list of distinct product codes from […]
I want to add an identity or unique identifier column to a table in order to ensure that each row is unique. For best performance, which one should I use?
One of the key aspects of database table design is to ensure what is called entity integrity. What this means is that you need to ensure that each row in your database tables is unique. If you don’t take the proper precautions, it is possible that one or more rows of your table might be […]
Question Which of the following joins will produce better performance? ANSI JOIN Syntax SELECT fname, lname, departmentFROM names INNER JOIN departments ON names.employeeid = departments.employeeid Former Microsoft JOIN Syntax SELECT fname, lname, departmentFROM names, departmentsWHERE names.employeeid = departments.employeeid AnswerSQL Server supports two variations of performing JOINs: the ANSI JOIN syntax and the former Microsoft JOIN […]
I don’t like to delete records in our production database, even though we will never need them again. Does this affect performance?
Question I don’t like to delete records in our production database, even though we will never need them again. Because of this, I have included an extra column in every table called the “ACTIVE_FLAG” that is set to one character in length that contains either an “a” for active records or a “d” for deleted […]
In my stored procedures I have the option of calling the same data from either a table or a view. For best performance, should I be calling a table or a view?
Anytime you call data from a view instead of a table, there is additional overhead, which can hurt performance. Because of this, optimum performance can be had by calling your data directly from a table, not a view. If you don’t use the stored procedure often, the performance difference will not be noticeable if you […]
Yes, SQL Server’s performance can be affected by using NULLS in your database. There are several reasons for this. First, NULLS that appear in fixed length columns (CHAR) take up the entire size of the column. So if you have a column that is 25 characters wide, and a NULL is stored in it, then […]
Question I am a student at Virginia Tech and am writing a research paper for a class of mine about database performance issues. I found an article of yours online that was very informative and I was going to use it as a reference, but I have a question that I hope you could answer […]