An Approach for Optimization of Object Queries on Collections Using Annotations
Object oriented programming languages have raised the level of abstraction by supporting the object querying on collections. Programming languages can execute first class query constructs, using query optimization techniques from the database field, for run time optimizations. Existing approaches, however, such as Java Query Language (JQL), which executes such query constructs on collections have high run time overhead. Therefore, we propose an approach to reduce the burden of run time overhead by performing most of the query optimization for object queries on collections at compile time. This approach both analyzes the source code and obtains the metadata provided through annotations. It relies on building histograms from the metadata information. Then, the predicate and join selectivity estimates within a query are computed from these histograms. The selectivity estimates are maintained accurate with the incremental maintenance of histograms to the data changes in the program at run time. Next, both the selection and join optimizations are applied on the queries. The optimizations help in skipping and eliminating the execution of some of the predicates and joins based on the collected metadata. Finally, a query plan is generated at the compile time through the proposed selectivity cost heuristic. The query itself is executed at run time according to the determined query plan. But, in cases of inaccurate metadata and significant data changes in the source code, the query plan is modified at run time according to the correct selectivity estimates obtained from the updated histograms. Our experimental results demonstrate that our approach reduces the run time overhead of a program with collections more than the earlier approaches such as JQL.