Never write SELECT * FROM
The database server has to resolve fields according to the schema. If you know the schema, it is highly recommended to name the fields.
Use stored procedures
Stored procedures are more effective and resource efficient than SQL queries sent to the relational database management system (RDBMS) by the application server. There are two reasons for that:
- a stored procedure saves the server from interpreting the query as it is pre-compiled
- a stored procedure uses less bandwidth as there is less information transferred between the server and the client
You should therefore utilize this RDBMS function as much as possible.
All recent RDBMS (SQL Server, MySQL, PostgreSQL, etc.) support stored procedures.