Query optimization is an excellent opportunity to make your application run fast. An expert SQL developer can sometimes restructure existing queries and achieve improvements of over 2500 percent! This kind of improvement is possible because during development the first query that works is often the one that gets used for the final application.
Query optimization requires the study of:
While specific optimization techniques differ from one database to another, the general process of optimization must consider how the data is stored, the indexes, primary and foreign relations, triggers, selection filters, extended stored procedures, page fill factors, and the larger scope of servicing the application's data access requirements with minimal resource consumption.
One easy way to optimize your queries is to use stored procedures. Stored procedures are a lot faster than passing a query string. The reason is simple: stored procedures are already read, optimized, compiled, and ready to run. Another reason is that some ODBC drivers separately ask the server for each row, whereas a stored procedure can deliver the entire result set all at once.
For More Information For more information how to create and use stored procedures, search online for "Using Stored Procedures" in MSDN Library Visual Studio 6.0.
Query optimization is difficult and belongs to the specialists who can understand all of the data access performance issues.