Theory of Computing Systems

, Volume 57, Issue 4, pp 1202–1249 | Cite as

Structural Tractability of Counting of Solutions to Conjunctive Queries



We explore the complexity of counting solutions to conjunctive queries, a basic class of queries from database theory. We introduce a parameter, called the quantified star size of a query ϕ, which measures how the free variables are spread in ϕ. As usual in database theory, we associate a hypergraph to a query ϕ. We show that for classes of queries for which these associated hypergraphs admit good decompositions, e.g., bounded width generalized hypertree decompositions, bounded quantified star size exactly characterizes the subclasses of hypergraphs for which counting the number of solutions is tractable. In the case of bounded arity, this allows us to fully characterize the classes of hypergraphs for which counting the solutions is tractable. Finally, we also analyze the complexity of computing the quantified star size of a conjunctive query.


Conjunctive queries Counting complexity Hypergraph decomposition techniques 



The authors are grateful for the very helpful feedback on this paper they got from the reviewers of the conference version. The results of this paper are a part of the PhD thesis of the second author [29]. During the writeup process of this thesis, Peter Bürgisser gave valuable feedback that helped immensely to improve the presentation of the thesis and thus also of this paper. The authors are very thankful for this.


  1. 1.
    Abiteboul, S., Hull, R., Vianu, V.: Foundations of Databases. Addison-Wesley (1995)Google Scholar
  2. 2.
    Adler, I., Gottlob, G., Grohe, G.: Hypertree width and related hypergraph invariants. Eur. J. Comb. 28(8), 2167–2181 (2007)MATHMathSciNetCrossRefGoogle Scholar
  3. 3.
    Bagan, G., Durand, A., Grandjean, G.: On acyclic conjunctive queries and constant delay enumeration. In: CSL’07, 16th Annual Conference of the EACSL, LNCS, vol. 4646, pp 208–222. Springer (2007)Google Scholar
  4. 4.
    Bodlaender, H.: A linear time algorithm for finding tree-decompositions of small treewidth. In: Proceedings of the 25th Annual ACM Symposium on Theory of Computing, pp 226–234. ACM (1993)Google Scholar
  5. 5.
    Bodlaender, H.: A partial k-arboretum of graphs with bounded treewidth. Theor. Comput. Sci. 209(1-2), 1–45 (1998)MATHMathSciNetCrossRefGoogle Scholar
  6. 6.
    Bulatov, A., Dalmau, V., Grohe, M., Marx, D.: Enumerating homomorphisms. J. Comput. Syst. Sci. 78(2), 638–650 (2012)MATHMathSciNetCrossRefGoogle Scholar
  7. 7.
    Chen, H.: On the Complexity of Existential Positive Queries. ArXiv e-prints (2012)Google Scholar
  8. 8.
    Chen, H., Dalmau, V.: Beyond hypertree width: decomposition methods without decompositions. In: 11th international conference principles and practice of constraint programming, CP ’05, pp 167–181 (2005)Google Scholar
  9. 9.
    Chen, H., Dalmau, V.: Decomposing quantified conjunctive (or disjunctive) formulas. LICS (2012)Google Scholar
  10. 10.
    Cohen, D., Jeavons, P., Gyssens, M.: A unified theory of structural tractability for constraint satisfaction problems. J. Comput. Syst. Sci. 74(5), 721–743 (2008)MATHMathSciNetCrossRefGoogle Scholar
  11. 11.
    Courcelle, B.: Graph Rewriting: An Algebraic and Logic Approach. In: Handbook of theoretical computer science, volume B: Formal models and sematics (B), pp. 193–242 (1990)Google Scholar
  12. 12.
    Dalmau, V., Jonsson, P.: The complexity of counting homomorphisms seen from the other side. Theor. Comput. Sci. 329(1-3), 315–323 (2004)MATHMathSciNetCrossRefGoogle Scholar
  13. 13.
    Diestel, R.: Graph Theory. 2005. Grad. Texts in Math (2005)Google Scholar
  14. 14.
    Downey, R.G., Fellows, M.R.: Parameterized complexity, Vol. 3. Springer, New York (1999)Google Scholar
  15. 15.
    Durand, A., Mengel, S.: The Complexity of Weighted Counting for Acyclic Conjunctive Queries. Arxiv preprint arXiv:1110.4201 (2011)
  16. 16.
    Flum, J., Frick, M., Grohe, M.: Query evaluation via tree-decompositions. J. ACM 49(6), 716–752 (2002)MathSciNetCrossRefGoogle Scholar
  17. 17.
    Flum, J., Grohe, M.: Parameterized Complexity Theory. Springer-Verlag, New York Inc (2006)Google Scholar
  18. 18.
    Gottlob, G., Leone, N., Scarcello, F.: A comparison of structural CSP decomposition methods. Artif. Intell. 124(2), 243–282 (2000)MATHMathSciNetCrossRefGoogle Scholar
  19. 19.
    Gottlob, G., Leone, N., Scarcello, F.: Hypertree decompositions and tractable queries. J. Comput. Syst. Sci. 64(3), 579–627 (2002)MATHMathSciNetCrossRefGoogle Scholar
  20. 20.
    Gottlob, G., Miklós, Z., Schwentick, T.: Generalized Hypertree Decompositions: NP-hardness and tractable variants. J. ACM 56(6) (2009)Google Scholar
  21. 21.
    Greco, G., Scarcello, F.: Structural Tractability of Enumerating CSP Solutions. In: Proceedings of the 16th International Conference on Principles and Practice of Constraint Programming, CP ’10, pp 236–251 (2010)Google Scholar
  22. 22.
    Grohe, M.: The complexity of homomorphism and constraint satisfaction problems seen from the other side. J. ACM 54(1) (2007)Google Scholar
  23. 23.
    Grohe, M., Marx, D.: Constraint Solving via Fractional Edge Covers. In: 17th Annual ACM-SIAM Symposium on Discrete Algorithm, SODA ’06, pp 289–298. ACM, New York (2006)Google Scholar
  24. 24.
    Grohe, M., Schwentick, T., Segoufin, L.: When is the evaluation of conjunctive queries tractable?In: Proceedings of the 33rd Annual ACM Symposium on Theory of Computing, pp. 657–666. ACM (2001)Google Scholar
  25. 25.
    Gyssens, M., Jeavons, P., Cohen, D.A.: Decomposing constraint satisfaction problems using database techniques. Artif. Intell. 66(1), 57–89 (1994)MATHMathSciNetCrossRefGoogle Scholar
  26. 26.
    Kolaitis, P. G., Vardi, M. Y.: Conjunctive-Query Containment and Constraint Satisfaction. J. Comput. Syst. Sci. 61(2), 302–332 (2000)MATHMathSciNetCrossRefGoogle Scholar
  27. 27.
    Libkin, L.: Elements of Finite Model Theory, EATCS Series. Springer (2004)Google Scholar
  28. 28.
    Marx, D.: Approximating fractional hypertree width. ACM Trans. Algoritm. 6(2), 29:1–29:17 (2010)MathSciNetGoogle Scholar
  29. 29.
    Mengel, S.: Conjunctive Queries, Arithmetic Circuits and Counting Complexity. Ph.D. Thesis, University of Paderborn (2013)Google Scholar
  30. 30.
    Miklós, Z.: Understanding Tractable Decompositions for Constraint Satisfaction. Ph.D. Thesis, University of Oxford (2008)Google Scholar
  31. 31.
    Pichler, R., Skritek, A.: Tractable Counting of the Answers to Conjunctive Queries. AMW (2011)Google Scholar
  32. 32.
    Robertson, N., Seymour, P.: Graph minors II: algorithmic aspects of tree-width. J. Algoritm. 7(3) (1986)Google Scholar
  33. 33.
    Yannakakis, M.: Algorithms for Acyclic Database Schemes, pp 82–94. VLDB (1981)Google Scholar

Copyright information

© Springer Science+Business Media New York 2014

Authors and Affiliations

  1. 1.Université Paris DiderotInstitut de Mathématiques de JussieuParisFrance
  2. 2.Department of MathematicsTechnische Universität BerlinBerlinGermany

Personalised recommendations