Home

Queries should not SELECT too many columns

Description

    The Pl_Sql code rule "Queries should not SELECT too many columns" states that when writing SQL queries, it is best to only select the columns that are necessary for the query. Selecting too many columns can lead to performance issues, as the query will take longer to execute. Additionally, selecting too many columns can lead to confusion and make it difficult to interpret the results. It is best to only select the columns that are necessary for the query, and avoid selecting any unnecessary columns.

Key Benefits

  • Reduced Processing Time: By selecting fewer columns, the query processor can spend less time processing the data and return results faster.
  • Reduced Network Traffic: By selecting fewer columns, the query processor can send less data over the network, reducing network traffic.
  • Improved Performance: By selecting fewer columns, the query processor can use fewer resources and run faster.
  • Improved Security: By selecting fewer columns, the query processor can reduce the risk of exposing sensitive data.

 

Non-compliant Code Example

SELECT          --Non compliant code (Select query containing columns more then default defined limit of 6 columns)
    NAME,
    ADDRESS,
    CREDIT_LIMIT,
	AREA_CODE,
	PHONE_NUMBER,
	LANDMARK,
	TOTAL_EXPENSE
FROM
    CUSTOMERS
WHERE
	CREDIT_LIMIT IS NOT NULL
Visual Expert 2024
 VEPLSQLRULE152