how to improve select query performance? if table with millions of record
Loading
how to improve select query performance? if table with millions of record
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anant VernekarPosted Jul 4, 2021, 6:13 AM
1. Use EXISTS instead of IN to check existence of data
2. Avoid * in SELECT statement. Give the name of columns which you require
3.Avoid Having Clause. Having clause is required if you further wish to filter the result of an aggregations.
4.Create Clustered and Non-Clustered Indexes.Keep clustered index small since the fields used in clustered index may also used in non-clustered index.
5.Most selective columns should be placed leftmost in the key of a non-clustered index.Drop unused Indexes.
6.Better to create indexes on columns that have integer values instead of characters. Integer values use less overhead than character values.
7.Use joins instead of sub-queries
8.Avoid Cursors since cursor are very slow in performance
You can refer this article for more elobration...
https://www.c-sharpcorner.com/UploadFile/f0b2ed/tips-to-increase-sql-server-query-performance-part-1/
Nabin AgarwalaPosted Jul 4, 2021, 8:49 AM