One embodiment of the present invention provides a
system that optimizes the execution of a
database query involving a target partitioned-
database-object. During
system operation, the
database receives a query. If the query has a predicate that includes a partition-mapping function that uses the partitioning schema of a partitioned database-object and a
list of columns from one or more tables to express a mapping of the
list of column values to the partitions of the partitioned database-object, the
system determines the compatibility of the partitioning schemas of the target partitioned-database-object and the partitioned database-object. Next, if the partitioning schemas are compatible, and if the
list of columns is compatible with the partitioning keys of the target partitioned-database-object and the partitioned database-object, the system attempts to identify a subset of partitions in the target partitioned-database-object that satisfy the predicate. Finally, if a subset of partitions is successfully identified, the system performs the query only on the identified subset of partitions, and not on the other partitions, thereby optimizing the execution of the query by reducing the number of partitions that need to be accessed.