Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Does the Transact-SQL code return more data than needed?

0
Posted

Does the Transact-SQL code return more data than needed?

0

The less data returned by SQL Server, the less resources SQL Server needs to operate, helping to boost the overall performance of SQL Server. This may sound obvious, but returning unnecessary data is a performance problem that I see over and over. Here are some of the most common mistakes made by coders when returning data from SQL Server that results in more data than necessary: • The absence of a WHERE clause. Unless you want to return all data from a table, which is a rare activity, the use of a WHERE clause is necessary to reduce the number of rows returned. • As an adjunct to the above advice, a WHERE clause needs to be a selective as possible. For example, if you only need to return records from a particular date, don’t return all the records for the month, or year. Design the WHERE clause so that exactly only those rows you need returned are returned, and not one extra row. • In the SELECT clause, only include those columns that you need, not all of them. Along the same line, do

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123