Oct 30 2008

Quick tips for database programmers

Since you are smart, you know these things anyway. Just tell your friends too.

Avoid using select * from in your queries.

Why? Selecting every column in the table reduces the performance of the database, the network and the application in general.

Alternative: Use something like select required_column1, required_column2,… from table_name instead.

Avoid using code like a = resultSet.fields(1); in your application

Why? When somebody changes the query, 1 may refer to another column.

Alternative: Use code like a = resultSet.fileds(“column_name”);

Never assume same order of records when a query is fired multiple times.

Why? Each database engine retrieves records using different optimization techniques. The order of the records fetched may vary each time due to difference in different system conditions.

Alternative: Try to use order by clause in your queries wherever applicable. (Remember that there is a performance penalty associated with the order by clause)

Trackback URI | Comments RSS

Leave a Reply