1. A method of optimizing execution of a query against a database in a datastore of a computer, the method comprising: identifying a first query predicate in the query, wherein the first query predicate comprises a comparison between a first data type and a second data type, and wherein the first data type is different from the second data type; generating a second query predicate with matching data types, wherein the second data type is converted to the first data type; and executing the second query predicate against the database to obtain a subset of records.