sql queries are optimized to operate directly on compressed data rather than requiring that the data be first decompressed prior to processing a query . certain characteristic pattern trees are mapped against a logical input query plan that includes certain logical operators such as a decompress that precedes a join or a groupby in association with a count to identify instances in the plan that match a characteristic pattern . upon locating a match , the input query plan is transformed into a logically equivalent plan that operates correctly on compressed data , by analyzing the interplay of the semantics of logical query operations with the compressed data and substituting less costly structures and operations . decompress operations are moved to operate subsequent to a join or eliminated altogether , and count operations are replaced by a different operation , such as sum , that is logically equivalent for compressed data .