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.