We are facing a lot of performance problems in report sqls.While I spent a lot of time understanding how the optimizer interprets the sql written, I could not come to any conclusions. Its always baffling and frustrating trying to do this.
So, as a generic rule, I would like to know the best ways(guidelines) of writing a sql. And by any chance can we fool the optimizer for better perfomance - I've heard abt adding bogus predicates, etc, might improve query performance. Any help in this regd would be great.
This is a complicated question for which there is no easy answer. DB2 performance depends on several factors, not just the way the SQL is coded. Sometimes the SQL statement can be rewritten for better performance, but typically there are more fundamental problems that need to be addressed.
One of the most important factors to good performance is the design of the database (especially the table and index design). Without a good design, you are fighting an uphill battle.
I would suggest that try to get some consulting help if you don't have expertise in your organization. Someone could look at your installation and database design and give some good pointers in just a few days. Obviously, a complete redesign would probably require more than a few days.
The only other option would be for you to post the specific table and index design, and list the SQL queries that are giving you problems. Be sure to include as many details as possible, including table size and distribution of data. If you do this, please do not leave out any details and include the entire DDL of all the relevant objects.