• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

10774: SQL Query Performance Tuning

Hello experts:

Based on your experience, I can recommend very good articles on this topic: SQL Query Performance Tuning
0
enrique_aeo
Asked:
enrique_aeo
  • 3
1 Solution
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
What's the question?
0
 
enrique_aeoAuthor Commented:
What are the problems with table indexes database.
0
 
enrique_aeoAuthor Commented:
I prefer URL with T-SQL
0
 
enrique_aeoAuthor Commented:
Please experts

code T-SQL for to close the question

"1. Don't use UPDATE instead of CASE
This issue is very common, and though it's not hard to spot, many developers often overlook it because using UPDATE has a natural flow that seems logical.

Take this scenario, for instance: You're inserting data into a temp table and need it to display a certain value if another value exists. Maybe you're pulling from the Customer table and you want anyone with more than $100,000 in orders to be labeled as "Preferred." Thus, you insert the data into the table and run an UPDATE statement to set the CustomerRank column to "Preferred" for anyone who has more than $100,000 in orders. The problem is that the UPDATE statement is logged, which means it has to write twice for every single write to the table. The way around this, of course, is to use an inline CASE statement in the SQL query itself. This tests every row for the order amount condition and sets the "Preferred" label before it's written to the table. The performance increase can be staggering."
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now