Advertise at FreeMegaZone
Give tremendous boost to your business by advertising at FreeMegaZone. Contact webmaster@freemegazone.com |
|
|
|
|
Author: P.V.Neir
Being developer we usually see clients complaining about database performance. Performance problems arise when we ignore the good practices. In this article I am listing the best practices you must follow while working with SQL.
- The database design should be simple and clear. It should be user friendly. It should have flexible structure so that depending on the future requirements the database can easily be expanded.
- Store relevant and necessary information in the database.
- Use normalized tables in the database. It is better to use small multiple tables instead of using one large table.
- Use denormalization as the last option for your database.
- Use database look up tables. It will help you maintain data integrity of your database.
- Use numeric or small width primary key for your database tables. Processing small data takes less time.
- Do not store images in the database. Store URLs of images instead.
- Do not display SQL errors to users. Most of the attackers get benefit of error messages.
- Make an ERROR table in the database. Storing errors in the ERROR table will help you keep track of bugs.
- Assign proper data types to the fields in the database. It is better to use TINYINT for age rather than VARCHAR (45).
- Use database field names in SELECT, INSERT, UPDATE commands. Avoid using SELECT * or INSERT INTO TABLE VALUES (value1, value2…).
- Use LIKE clause properly. Improper usage may cause performance problems in your database.
- Use database server's timestamp instead of web server's timestamp.
- Use alias in the SQL statements which require multiple tables.
- Write SQL commands in capital letters. It helps in readability.
- Use nested queries as minimum as possible. Use JOIN statement instead.
- Avoid query running in the loop.
- Use stored procedures. They are fast and help in maintainability and security of the database.
- Avoid CURSOR, GOTO and IF statements. Prefer SWITCH CASES.
- Use comments.
- Do proper indexing. It will improve the speed of operations in the database tables. Improper or too much indexing affects performance of the database.
- Use inet_aton() function to store IPs as integers in the database. The inet_aton() function converts the string, in the Internet standard dot notation, to a network address, and stores the address in the structure provided.
- Retrieve the IPs with inet_ntoa() function. The inet_ntoa() function converts the specified Internet host address to a string in the Internet standard dot notation.
- Always encrypt the sensitive data.
- Do not rely on server configurations. Always write the most portable code possible.
- Do proper documentation of your application.
- Always do testing of your database application. Make cases based on requirements and maintain a checklist of the tests.
More Oracle Articles, Database Articles and DBA Tips
Database Security: Step by step guideline
Oracle – SQL Guide for Parallel Stored Procedures
Great Tips on Oracle Applications Security!
Great Tips for Test Data Generation in Oracle!!
Oracle Guide for Disk I/O tuning!!
|