1. A method for optimizing a database query in a computer of the type including a database management system, the database query including criteria that references a plurality of tables in order to re-order a result set generated for the database query, the method comprising the steps of, in the computer: applying transitive closure analysis to at least one search condition in the query to identify an equivalent field for a field referenced in the criteria, wherein the criteria is one of a GROUP BY clause and an ORDER BY clause; and based on the transitive closure analysis, rewriting the criteria to generate modified criteria to reduce the number of tables referenced thereby by substituting the equivalent field for the field referenced in the criteria, including rewriting the criteria to generate modified criteria that references only one table, based on the transitive closure analysis.