Rule Definition
A query that retrieves all columns of a table with a SELECT * can potentially be the source of important changeability problems. One cannot control how the columns will be ordered and returned to the client. This can lead to important data inconsistencies and thus stability issues.
Also performance problems may arise when the execution of the query returns a large result sets (many row with all the columns may then become a huge amount of data to transport over the network). Thus optimizer module can't provide a correct execution.
Remediation
Review the design of the query to select only useful columns.
Violation Code Sample
https://docs.oracle.com/middleware/1221/bip/BIPDM/best_practices.htm#CHDIBFEE
SELECT * FROM EMPLOYEES;
Fixed Code Sample
https://docs.oracle.com/middleware/1221/bip/BIPDM/best_practices.htm#CHDIBFEE
1. Always select only the columns you need:
SELECT DEPARTMENT_ID, DEPARTMENT_NAME FROM EMPLOYEES;
or
2. Use a WHERE clause and bind parameters whenever possible to restrict the returned data more precisely:
SELECT DEPARTMENT_ID, DEPARTMENT_NAME
FROM EMPLOYEES
WHERE DEPARTMENT_ID IN (:P_DEPT_ID)
Reference
Oracle® Fusion Middleware Data Modeling Guide for Oracle Business Intelligence Publisher
Only Return the Data You Need
https://docs.oracle.com/middleware/1221/bip/BIPDM/best_practices.htm#CHDIBFEE
Google Cloud BigQuery - Optimize queries - Optimize query computation
https://cloud.google.com/bigquery/docs/best-practices-performance-compute#avoid_select_
Top five query tuning techniques for Microsoft SQL Server - Don't select everything
https://www.dbvis.com/thetable/top-five-query-tuning-techniques-for-microsoft-sql-server/
Snowflake Query Optimization Techniques - 1. Select fewer columns
https://select.dev/posts/snowflake-query-optimization#1-select-fewer-columns
Medium Blog - 5 Reasons Why Using SELECT * in SQL Queries Should be Avoided
https://medium.com/@pradeeptiwari.bhumca10/5-reasons-why-using-select-in-sql-queries-should-be-avoided-1417ef433a92
Related Technologies
Technical Criterion
Efficiency - SQL and Data Handling Performance
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.