Improving performance by limiting the number of columns and rows
It has been observed that many developers tend to use SELECT *
in queries even if only a few columns of the tables are needed. It's also observed that, many a time, people execute the SELECT
query without applying a proper filter clause, which returns more rows in the result set than actually required. After returning result sets to the application, filtering rows in the result sets in application logic as and when needed which is not really a good practice. Both of these cases create big result sets with unnecessary columns and rows, which has many drawbacks. The following are the few of them:
A big result set creates I/O overhead by reading more columns/rows from the pages that can be ignored, which in fact is actually not needed.
Creates unnecessary load on network traffic.
The
SELECT *
query withJOIN
may create some issues and throw an error while using theORDER BY
clause on columns, which are common in more than one table...