What are the factors you will check for the performane
optimization for a database query?
Answer Posted / samba shiva reddy . m
1.In the select statement give which ever the columns you need
don't give select * from
2.Do not use count()function
3.use indexes and drop indexes regularly it B tree structure we are not going to drop means it will take time for creating indexes it self.
4.when joining the tables use the id's(integer type)not string
5.Sometimes you may have more than one subqueries in your main query. Try to minimize the number of subquery block in your query.
6.Use operator EXISTS, IN and table joins appropriately in your query.
a) Usually IN has the slowest performance.
b) IN is efficient when most of the filter criteria is in the sub-query.
c) EXISTS is efficient when most of the filter criteria is in the main query.
7.Use EXISTS instead of DISTINCT when using joins which involves tables having one-to-many relationship.
8.Try to use UNION ALL in place of UNION.
9.Avoid the 'like' and notlike in where clause.
10.Use non-column expression on one side of the query because it will be processed earlier.
11.To store large binary objects, first place them in the file system and add the file path in the database.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How do I view views in sql server?
Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.
Can we do dml on views?
How can you fetch alternate records from a table?
How to change the name of a database user?
mention different types of relationships in the dbms?
What do you understand by mirroring and mention the advantages of the mirroring?
Explain what is the function of sql server agent windows service?
Tell me time data type, datetime2, datetimeoffset data type in sql server 2008?
What is tempdb database? : SQL Server Architecture
How do I setup a local sql server database?
how can you attach more than 20 ldf files in sql server
What do you understand by triggers?
What is TDS(Tabular Data Stream) Gateway?
Can foreign key be deleted?