1. A method of optimizing a database query, the method comprising: receiving a first database query where at least one field is materialized into a first temporary table during execution of the first database query, wherein the field is associated with a second database query; merging at least one predicate from the first database query with at least one predicate from the second database query; generating a first statistic for the first temporary table prior to creation of the first temporary table based upon the merged predicates from the first and second database queries, wherein the first statistic includes a cardinality for at least one column of the first temporary table; and optimizing the first database query using the first statistic.