The Dilemma of Encapsulation Versus Query Optimization
July 21, 2005 Abstract: There is a fundamental, irreconcilable conflict between the goals of encapsulation and the goals of query optimization. The object-oriented literature emphasizes encapsulation. An object should access only objects that are directly related. An object can access indirectly related objects via the methods of intervening objects. Encapsulation increases the resilience of an application; local changes to an application model cause local changes to application code. On the other hand, database management system (DBMS) optimizers take a logical request and generate an execution plan. If queries are broadly stated, the optimizer has greater freedom for devising an efficient plan. Thus encapsulation boosts resilience but limits optimization potential. On the other hand, broadly stating queries is conducive to optimization, but a small change to an application can affect many queries.