• Repost - originally posted 29-08-2012

Reviewing queries - columns, joins, tables and indexes

Whilst rewriting a lot of T-SQL code to allow a client to change their report delivery mechanism, what we found is that the current queries return columns that are not used. This may have been because some queries had been copied from others and have never been reviewed or refactored. For more efficient code we have removed these columns that were not needed. As we removed the columns we also found that there were tables and therefor table joins that were no longer required. So the joins got removed as well and some tables. We then made sure that the columns on every table join were also indexed.The result is leaner, more efficient, quicker and more manageable code.

2 views0 comments

Recent Posts

See All

Cardinality estimator

Recently I was asked by a software vendor to review a particular query that ran in under a second on a SQL Server 2014 installation at a compatibility level of 110 (SQL Server 2012), but when run unde

Index fragmentation

A law firm client, occasionally has issues with their legal software, that is provided by the global leader in this field. The response from the software provider is always the same - you have index f

Deleting large amounts of data

I had a client call me about wanting to delete a large amount of data from their database. They knew what tables they wanted to delete from. They also knew that deleting large amounts of data causes t