Utpal Writes - on a project called life...

Seven Points To Ponder On SQL Database Optimization

by Utpal Vaishnav on January 2, 2009

  1. Know your data: I often see queries where a developer has taken a crazy route to get to some data where a much simpler path could have been used. This is often the result of bad schema design choices.
  2. Understand real-world use patterns: Understand how will the data actually be queried. Does your schema support these queries properly and easily?
  3. Fix your database schema: A better schema will allow developers to write better queries and better queries will be faster queries. Simple as that. And speaking of tricks, avoid creating tricky schemas. Entity-Attribute-Value (EAV) is a good example; is it really that difficult to create an additional column when you need a new attribute?
  4. Fix the queries: If you’ve done all you can with the schema, start looking at the queries. Are they unnecessarily using cursors? Extensive use of temporary tables? Nonsargable predicates?
  5. Index Effectively: Notice that this is step #5. If at all possible, fix the schema and the data before you get to this step. Indexing is a great tool, but we often tend to use it as a crutch to fix problems that were created at other stages of the design process.
  6. Know the Hardware: It’s difficult to specify hardware without understanding something about data volumes, use patterns, and the like. How could you possibly know how many bytes/second your disk system needs to be able to serve up without knowing how many bytes/second your queries will be consuming? The vast majority of systems I see were designed based on guesswork at best, and oftentimes no information at all. Databases are not all created equal, and neither are servers.
  7. Be Specific: Don’t guess. Don’t try to be tricky. Collect metrics, apply them to your knowledge of the system, and create solutions.

See Also:

  1. Five Points To Be Considered While Opting For Website Development

Previous post:

Next post: