Best Online Tutorials

SQL Tutorial

Free SQL Tutorial

SQL Interview Questions

SQL Practice Questions

SQL Tips & Tricks

SQL Errors

SQL Books

Angular Tutorial

Free Angular Tutorial

Angular Interview Questions

Angular Practice Questions

Angular Tips & Tricks

Angular Errors

Angular Books

Node.js Tutorial

Free Node.js Tutorial

Node.js Interview Questions

Node.js Practice Questions

Node.js Tips & Tricks

Node.js Errors

Node.js Books

React.js Tutorial

Free React.js Tutorial

React.js Interview Questions

React.js Practice Questions

React.js Tips & Tricks

React.js Errors

React.js Books

SSIS Tutorial

Free SSIS Tutorial

SSIS Interview Questions

SSIS Practice Questions

SSIS Tips & Tricks

SSIS Errors

SSIS Books

SEO Tutorial

Free SEO Tutorial

SEO Interview Questions

SEO Practice Questions

SEO Tips & Tricks

SEO Errors

SEO Books

Javascript Tutorial

Free Javascript Tutorial

Javascript Interview Questions

Javascript Practice Questions

Javascript Tips & Tricks

Javascript Errors

Javascript Books

MongoDB Tutorial

Free MongoDB Tutorial

MongoDB Interview Questions

MongoDB Practice Questions

MongoDB Tips & Tricks

MongoDB Errors

MongoDB Books

Next.js Tutorial

Free Next.js Tutorial

Next.js Interview Questions

Next.js Practice Questions

Next.js Tips & Tricks

Next.js Errors

Next.js Books

Ways to Improve SQL Query Performance 

Prashant Surya  |   Oct 7, 2019  |  Views: 1174
pictures

Description:

There are many questions on the topic to improve SQL Performance, some of them are listed below, which are mostly asked in the interview.

How can I improve SQL query performance?

How can I improve my database performance?

How do I increase the performance of a selected query in MySQL?

What is SQL performance tuning?

How can you increase SQL performance?

How can SQL Server improve SQL performance?


Answer to all question:

Developer writes SQL Queries to fetch records as per client/user Requirements in proper way but Every User/Client wants a fast response to retrieve data. 

So we need write query that provides best performance. 

You can choose below methods to improve SQL query performance.

1. Avoid * in select clause: 


Specify the required columns instead of using *. 


Unused columns will take more spaces on database and query will be slow down.


Write queries like below sample, specifying only the required column.


Ex : SELECT Column1, Column2 FROM Table





2. UNION should be used if it is required.:

UNION fetch unique records, which slows down the SQL Query performance. 


Ex :SELECT Column1, Column2 FROM Table1
       UNION
SELECT Column1, Column2 FROM Table2




3. Cluster and Non Cluster Index:

 Cluster and Non Cluster Index should be creating to increase query performance. 

Unnecessary  use of indexes takes extra spaces and memory and creates load on the database. So index should only be used if it is required.





4. Joins should be used instead of Sub Queries:

Don't write sub-queries until there is no another away to retrieve data. Use available joins to filter your records.

This makes the query neat , clean , and easy to understand.

Ex :SELECT ID, Column1, Column2 FROM Table1 Join Table 2 on Table1.Id=Table2.Id

 


5. Avoid using cursor : 

Always try to minimize the use of Cursor because cursor is used for looping, and looping causes load in memory and thus consumes more time, and the SQL Query will slow down, its performance will be decreased.



Summary:

Keep these points in your mind while writing a SQL query, our aim should not be to get the result only, but it should be that to get results in the best way which increases the performance as well.


Comments:
Content Contributor
Prashant Surya

Prashant Surya

Software developer at Uniserve Data Technologies Pvt. Ltd.  |   Noida, Uttar Pradesh, India

I am a software developer, freelancer and trainer working on technologies likes. MEAN stack, MERN Stack, ASP.NET full stack, WebRTC, socket.io ,PWA, SQL, JavaScript, jQuery, HTML, CSS, SEO, responsive UI/UX designing... having 7 years of experience in development in multiple domains like, eCommerce, RTA, capital markets, education, real estate...


Read related articles

SQL Sever-Disk Usage Reports

Pooja Goel  |   Jun 20, 2020  |  Views: 513

How to optimize the Query in SQL SERVER

Pooja Goel  |   Jun 16, 2020  |  Views: 406

SQL Server - ORDER by using @Parameter

Pooja Goel  |   Jun 13, 2020  |  Views: 314

What is ACID fundamental

Prashant Surya  |   Mar 18, 2020  |  Views: 160

What is SQL Injection

Prashant Surya  |   Mar 18, 2020  |  Views: 253

Best website to learn SQL for free

Prashant Surya  |   Jan 24, 2020  |  Views: 185

SQL Tutorials Online

Prashant Surya  |   Jan 24, 2020  |  Views: 229

Top 10 SQL tutorial

Prashant Surya  |   Jan 24, 2020  |  Views: 224

SQL Tutorial

Prashant Surya  |   Jan 24, 2020  |  Views: 194

SQL Tutorials

Prashant Surya  |   Jan 24, 2020  |  Views: 219

Best SQL Tutorial

Prashant Surya  |   Jan 24, 2020  |  Views: 237

Advanced SQL Tutorial Topics - DritalConnect

Prashant Surya  |   Dec 21, 2019  |  Views: 340

Ways to get Execution Plan of Running SQL Query

Pooja Goel  |   Dec 4, 2019  |  Views: 653

Best SQL book for beginners - SQL Tutorial

Pooja Goel  |   Nov 23, 2019  |  Views: 314

Top 30 SQL Interview practice questions

Prashant Surya  |   Nov 23, 2019  |  Views: 417

Best website to learn sql tutorial online

Prashant Surya  |   Nov 22, 2019  |  Views: 226

SQL tutorials - DritalConnect

Prashant Surya  |   Nov 20, 2019  |  Views: 285

Performance tuning in SQL Server

Pooja Goel  |   Oct 19, 2019  |  Views: 1237

Ways to call SSIS Package in CA Workload

Abhishek Roy  |   Oct 9, 2019  |  Views: 559

Ways to Improve SQL Query Performance

Prashant Surya  |   Oct 7, 2019  |  Views: 1175

Want to sell your software ?-

If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.

  • Sell ERP
  • Sell Website Clones
  • Sell App Clones
  • Sell Readymade Portals
  • Sell Readymade Websites
  • Sell Mobile Apps
  • Sell Window Apps

Clients will find it using our advanced search filter and will contact you directly.

No any charge for the product lsiting.

Do you own a Company ?+

Property.sale

Buy or Sell Commercial Property+

Are you a freelancer ?+

Looking for a job ?+

Are you a Service Provider ?+

Are you a blogger ?+

Do you own an IT Institute ?+



Property.sale