Abstract
Sort orders play an important role in query evaluation. Algorithms that rely on sorting are widely used to implement joins, grouping, duplicate elimination and other set operations. The notion of interesting orders has allowed query optimizers to consider plans that could be locally sub-optimal, but produce ordered output beneficial for other operators, and thus be part of a globally optimal plan. However, the number of interesting orders for most operators is factorial in the number of attributes involved. Optimizer implementations use heuristics to prune the number of interesting orders, but the quality of the heuristics is unclear. Increasingly complex decision support queries and increasing use of query-covering indices, which provide multiple alternative sort orders for relations, motivate us to better address the problem of choosing interesting orders. We show that even a simplified version of the problem is NP-hard and provide a 1/2-benefit approximation algorithm for a special case of the problem. We then present principled heuristics for the general case of choosing interesting orders. We have implemented the proposed techniques in a Volcano-style cost-based optimizer, and our performance study shows significant improvements in estimated cost. We also executed our plans on a widely used commercial database system, and on PostgreSQL, and found that actual execution times for our plans were significantly better than for plans generated by those systems in several cases.
Similar content being viewed by others
References
Cao, Y., Bramandia, R., Chan, C.-Y., Kian-Lee, T.: Optimized query evaluation using cooperative sorts. In: International Conference on Data Engineering (2010)
Claussen J., Kemper A., Kossmann D., Wiesner C.: Exploiting early sorting and early partitioning for decision support query Processing. VLDB J. Very Large Data Bases 9(3), 190–213 (2000)
Diaz J., Petit J., Maria S.: A survey of graph layout problems. ACM Comput. Surv 34(3), 313–356 (2002)
Estivill-Castro V., Derick W.: A survey of adaptive sorting algorithms. ACM Comput. Surv 24(4), 441–476 (1992)
Goetz, G.: Implementing sorting in database systems. ACM Comput. Surv. 38(3), (2006)
Graefe, G., Bunker, R., Cooper, S.: Hash joins and hash teams in Microsoft SQL Server. In: International Conference on Very Large Databases, pp. 86–97 (1998)
Graefe, G., McKenna, W.J.: The volcano optimizer generator: extensibility and efficient search. In: International Conference on Data Engineering (1993)
Guravannavar, R., Sudarshan, S.: Reducing order enforcement cost in complex query plans. In: International Conferences on Data Engineering (2007)
Kenkre S., Vishwanathan S.: The common prefix problem on trees. Inf. Process. Lett. 105(6), 245–248 (2008)
Knuth D.E.: The art of programming, vol. 3: sorting and searching. Addison Wesley Longman Publishing, Co. Inc., Redwood City (1998)
Larson P.: External sorting: run formation revisited. IEEE Trans. Knowl. Data Eng 15(4), 961–972 (2003)
Neumann, T., Moerkotte, G.: A combined framework for grouping and order optimization. In: International Conference on Very Large Databases (2004)
Neumann, T., Moerkotte, G.: An efficient framework for order optimization. In: International Conference on Data Engineering (2004)
Roy, P.: Multi-query optimization and applications. PhD thesis, Indian Institute of Technology, Bombay, Department of Computer Science and Engineering (2001)
Griffiths, S.P., Astrahan, M.M., Chamberlin, D.D., Lorie, R.A., Price, T.G.: Access path selection in a relational database management system. In: ACM SIGMOD (1979)
Simmen, D., Shekita, E., Timothy, M.: Fundamental Techniques for Order Optimization. In ACM SIGMOD (1996)
Wang, X., Cherniack, M.: Avoiding sorting and grouping in processing queries. In: International Conference on Very Large Databases (2003)
Zhou, J., Larson, P., Chaiken, R.: Incorporating partitioning and Parallel Plans into the SCOPE optimizer. In: International Conference on Data Engineering (2010)
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
Cite this article
Guravannavar, R., Sudarshan, S., Diwan, A.A. et al. Which sort orders are interesting?. The VLDB Journal 21, 145–165 (2012). https://doi.org/10.1007/s00778-011-0240-z
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00778-011-0240-z