Direct Access for Answers to Conjunctive Queries with Aggregation

Authors Idan Eldar , Nofar Carmeli , Benny Kimelfeld

Thumbnail PDF


  • Filesize: 0.84 MB
  • 20 pages

Document Identifiers

Author Details

Idan Eldar
  • Technion - Israel Institute of Technology, Haifa, Israel
Nofar Carmeli
  • Inria, LIRMM, Univ Montpellier, CNRS, France
Benny Kimelfeld
  • Technion - Israel Institute of Technology, Haifa, Israel

Cite AsGet BibTex

Idan Eldar, Nofar Carmeli, and Benny Kimelfeld. Direct Access for Answers to Conjunctive Queries with Aggregation. In 27th International Conference on Database Theory (ICDT 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 290, pp. 4:1-4:20, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)


We study the fine-grained complexity of conjunctive queries with grouping and aggregation. For some common aggregate functions (e.g., min, max, count, sum), such a query can be phrased as an ordinary conjunctive query over a database annotated with a suitable commutative semiring. Specifically, we investigate the ability to evaluate such queries by constructing in log-linear time a data structure that provides logarithmic-time direct access to the answers ordered by a given lexicographic order. This task is nontrivial since the number of answers might be larger than log-linear in the size of the input, and so, the data structure needs to provide a compact representation of the space of answers. In the absence of aggregation and annotation, past research provides a sufficient tractability condition on queries and orders. For queries without self-joins, this condition is not just sufficient, but also necessary (under conventional lower-bound assumptions in fine-grained complexity). We show that all past results continue to hold for annotated databases, assuming that the annotation itself is not part of the lexicographic order. On the other hand, we show infeasibility for the case of count-distinct that does not have any efficient representation as a commutative semiring. We then investigate the ability to include the aggregate and annotation outcome in the lexicographic order. Among the hardness results, standing out as tractable is the case of a semiring with an idempotent addition, such as those of min and max. Notably, this case captures also count-distinct over a logarithmic-size domain.

Subject Classification

ACM Subject Classification
  • Theory of computation → Database query languages (principles)
  • Theory of computation → Database query processing and optimization (theory)
  • aggregate queries
  • conjunctive queries
  • provenance semirings
  • commutative semirings
  • annotated databases
  • direct access
  • ranking function
  • answer orderings
  • query classification


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Guillaume Bagan, Arnaud Durand, and Etienne Grandjean. On acyclic conjunctive queries and constant delay enumeration. In Jacques Duparc and Thomas A. Henzinger, editors, Computer Science Logic, pages 208-222, Berlin, Heidelberg, 2007. Springer Berlin Heidelberg. URL:
  2. Guillaume Bagan, Arnaud Durand, Etienne Grandjean, and Frédéric Olive. Computing the JTH solution of a first-order query. RAIRO - Theoretical Informatics and Applications (RAIRO: ITA), 42:147-164, 2008. URL:, URL:
  3. Christoph Berkholz, Jens Keppeler, and Nicole Schweikardt. Answering FO+MOD queries under updates on bounded degree databases. ACM Trans. Database Syst., 43(2):7:1-7:32, 2018. URL:
  4. Johann Brault-Baron. De la pertinence de l'énumération: Complexité en logiques propositionnelle et du premier ordre. Theses, Université de Caen, apr 2013. URL:
  5. Karl Bringmann, Nofar Carmeli, and Stefan Mengel. Tight fine-grained bounds for direct access on join queries. In PODS, pages 427-436. ACM, 2022. URL:
  6. Nofar Carmeli, Nikolaos Tziavelis, Wolfgang Gatterbauer, Benny Kimelfeld, and Mirek Riedewald. Tractable orders for direct access to ranked answers of conjunctive queries. In PODS, pages 325-341. ACM, 2021. URL:
  7. Nofar Carmeli, Shai Zeevi, Christoph Berkholz, Alessio Conte, Benny Kimelfeld, and Nicole Schweikardt. Answering (unions of) conjunctive queries using random access and random-order enumeration. ACM Trans. Database Syst., 47(3):9:1-9:49, 2022. URL:
  8. Henri Cohen. A course in computational algebraic number theory, volume 138 of Graduate texts in mathematics. Springer, 1993. URL:
  9. Sara Cohen, Werner Nutt, and Yehoshua Sagiv. Deciding equivalences among conjunctive aggregate queries. J. ACM, 54(2):5-es, apr 2007. URL:
  10. Idan Eldar, Nofar Carmeli, and Benny Kimelfeld. Direct access for answers to conjunctive queries with aggregation. CoRR, abs/2303.05327, 2023. URL:
  11. Anka Gajentaan and Mark H Overmars. On a class of o(n2) problems in computational geometry. Computational Geometry, 5(3):165-185, 1995. URL:
  12. Étienne Grandjean and Louis Jachiet. Which arithmetic operations can be performed in constant time in the ram model with addition?, 2022. URL:
  13. Todd J. Green, Grigoris Karvounarakis, and Val Tannen. Provenance semirings. In PODS, PODS '07, pages 31-40, New York, NY, USA, 2007. Association for Computing Machinery. URL:
  14. Muhammad Idris, Martin Ugarte, and Stijn Vansummeren. The dynamic yannakakis algorithm: Compact and efficient query processing under updates. In SIGMOD, pages 1259-1274, New York, NY, USA, 2017. Association for Computing Machinery. URL:
  15. Mahmoud Abo Khamis, Ryan R. Curtin, Benjamin Moseley, Hung Q. Ngo, XuanLong Nguyen, Dan Olteanu, and Maximilian Schleich. Functional aggregate queries with additive inequalities. ACM Trans. Database Syst., 45(4):17:1-17:41, 2020. URL:
  16. Mahmoud Abo Khamis, Hung Q. Ngo, and Atri Rudra. FAQ: questions asked frequently. In PODS, pages 13-28. ACM, 2016. URL:
  17. Dan Olteanu and Maximilian Schleich. Factorized databases. SIGMOD Rec., 45(2):5-16, 2016. URL:
  18. Dan Olteanu and Jakub Závodný. Size bounds for factorised representations of query results. ACM Trans. Database Syst., 40(1), mar 2015. URL:
  19. Mihai Patrascu. Towards polynomial lower bounds for dynamic problems. In Proceedings of the Forty-Second ACM Symposium on Theory of Computing, STOC '10, pages 603-610, New York, NY, USA, 2010. Association for Computing Machinery. URL:
  20. Christopher Ré and Dan Suciu. The trichotomy of HAVING queries on a probabilistic database. VLDB J., 18(5):1091-1116, 2009. URL:
  21. Thomas Schwentick, Nils Vortmeier, and Thomas Zeume. Dynamic complexity under definable changes. ACM Trans. Database Syst., 43(3):12:1-12:38, 2018. URL:
  22. Virginia Vassilevska Williams. Hardness of easy problems: Basing hardness on popular conjectures such as the strong exponential time hypothesis (invited talk). In IPEC. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2015. URL:
  23. Mihalis Yannakakis. Algorithms for acyclic database schemes. In VLDB, VLDB '81, pages 82-94. VLDB Endowment, 1981. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail