Comparing Execution Plans

Comparing execution plans is one of the most useful diagnostic tests you can do. If you’re lucky enough to have a good execution plan, you can use that plan as a guide to bring the bad execution plan into compliance. In Chapter 6 we talked about using SQL Profiles to apply a plan onto another database’s SQL, in order to have an emergency option. Suppose, however, you have more time to consider the difference and try to fix it properly, rather than using the SQL Profile sticking plaster. SQLTCOMPARE is the tool for the job. It will compare two target systems for the same SQL and produce a report that describes the differences. You can even import the SQLTXPLAIN repositories from the two target systems and do the comparison there. This chapter is a pure SQLTXPLAIN chapter, we will be using SQLTXPLAIN’s method SQLTCOMPARE and showing how our tuning knowledge from previous chapters can be used to diagnose a problem.