What is one of the first things you would do to increase
performance of a query? For example, a boss tells you that
?a query that ran yesterday took 30 seconds, but today it
takes 6 minutes?

Answers were Sorted based on User's Feedback



What is one of the first things you would do to increase performance of a query? For example, a bos..

Answer / bhaskar

Can u check the folliwing points are used in the procedure
or a Query.

Table should have primary key
Table should have minimum of one clustered index
Table should have appropriate amount of non-clustered index
Non-clustered index should be created on columns of table
based on query which is running
Following priority order should be followed when any index
is created a) WHERE clause, b) JOIN clause, c) ORDER BY
clause, d) SELECT clause
Do not to use Views or replace views with original source
table
Triggers should not be used if possible, incorporate the
logic of trigger in stored procedure
Remove any adhoc queries and use Stored Procedure instead
Check if there is atleast 30% HHD is empty - it improves
the performance a bit
If possible move the logic of UDF to SP as well
Remove * from SELECT and use columns which are only
necessary in code
Remove any unnecessary joins from table
If there is cursor used in query, see if there is any other
way to avoid the usage of this (either by SELECT … INTO or
INSERT … INTO, etc)
There are few hardware upgrades can be considered as well
like separating index on different disk drive or moving
tempdb to another drive. However, I am not suggesting them
here as they are not quick way to improve the performance
of query.

Is This Answer Correct ?    16 Yes 2 No

What is one of the first things you would do to increase performance of a query? For example, a bos..

Answer / george

I think the first thing we need to check for the index
defragmentation, truncating transaction log and shrinking
the tempdb as well, this is because first time the query
get executed in the short time only 30 Sec, however second
day time execution increased

Is This Answer Correct ?    8 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What does it mean to be in union?

0 Answers  


What is Stored Procedure? What is Views in sql server? Difference between a User Defined Function and a Stored Procedure Difference between a primary key and a unique key? What is a join and explain different types of joins. Difference between temp table and table variable Difference between Triggers and Stored Procedures Difference between UNION ALL Statement and UNION What is COALESCE / Why do we use COALESCE? Why we use SET ROWCOUNT in Sql How many clustered index can have a table How many types of local tables in SQL SERVER Difference between DELETE and TRUNCATE What is Aggregate Functions? What is Row_Number()? What are Ranking Functions? What is NOLOCK? What is CTE? What are the Advantages of using CTE? What is the STUFF function and how does it differ from the REPLACE function? What are the difference between clustered and a non-clustered index? What are the different index configurations a table can have? Difference between a HAVING CLAUSE and a WHERE CLAUSE? Difference between SET and SELECT Provide all the built in string function of SQL SERVER Difference between char and varchar data types Define candidate key, alternate key, composite key. What are constraints? Explain different types of constraints. What is a self join? Explain it with an example. How will you convert table row to a column comma separated value

4 Answers   ACS,


you notice that the transaction log on one of your databases is over 4gb the size of the data file is 2mb what could cause this situation, and how can you fix it? : Sql server administration

0 Answers  


System variable and temporary variables

0 Answers   Wipro,


how many layers of tcp/ip protocol combined of? : Sql server database administration

0 Answers  






What are the differences between union, intersect, and minus operators?

0 Answers  


What are the disadvantages of indexes?

0 Answers  


how to find number of columns in a table in sql server 2000 and 2005 also

16 Answers   Virtusa,


What is the difference between locking and multi-versioning?

0 Answers  


What is trigger and different types of Triggers?

0 Answers   QuestPond,


Difference between writing SQL query and stored procedure ?

15 Answers   Cognizant, Infosys, TCS, Veritas,


what is lazy writer?

1 Answers   Wipro,


Categories