Exploiting uniqueness in query optimization

  • Authors:
  • G. N. Paulley;Per-Åke Larson

  • Affiliations:
  • IBM Canada Ltd., North York, Ontario;IBM Canada Ltd., North York, Ontario

  • Venue:
  • CASCON '93 Proceedings of the 1993 conference of the Centre for Advanced Studies on Collaborative research: distributed computing - Volume 2
  • Year:
  • 1993

Quantified Score

Hi-index 0.00

Visualization

Abstract

Consider an SQL query that specifies duplicate elimination via a DISTINCT clause. Because duplicate elimination often requires an expensive sort of the query result, it is often worthwhile to identify situations where the DISTINCT clause is unnecessary, to avoid the sort altogether. We prove a necessary and sufficient condition for deciding if a query requires duplicate elimination. The condition exploits knowledge about keys, table constraints, and query predicates. Because the condition cannot always be tested efficiently, we offer a practical algorithm that tests a simpler, sufficient condition. We consider applications of this condition for various types of queries, and show that we can exploit this condition in both relational and nonrelational database systems.