TL;DR
The paper introduces dpdb, a novel framework that implements dynamic programming on tree decompositions directly inside a relational database management system (PostgreSQL) using SQL. By mapping graph-theoretic operations to relational algebra, the authors leverage decades of database optimization to solve hard counting problems (like #SAT) while elegantly handling massive intermediate tables that would otherwise exhaust main memory.
What Problem Does This Paper Address?
Counting problems, such as #SAT (counting the number of satisfying assignments for a Boolean formula), are notoriously difficult (#P-complete) but crucial for real-world applications in hardware verification, probabilistic reasoning, and artificial intelligence.
Structural graph parameters like treewidth offer a theoretical lifeline: if an instance's underlying graph structure is tree-like (low treewidth), we can solve the problem efficiently using dynamic programming (DP) over a tree decomposition. However, turning this theory into practice is brutal. The intermediate tables tracking variable assignments grow exponentially with the treewidth, quickly exhausting RAM. Writing custom, optimized memory-management and parallel execution code for every new problem is tedious and error-prone.
Methods
The authors bridge the gap between graph theory and practical systems by realizing that dynamic programming on tree decompositions is fundamentally an exercise in table manipulation. They map the standard steps of tree-decomposition algorithms directly to relational algebra:
- Introduce Nodes: Map to $\theta$-joins with initial truth assignments.
- Removal Nodes: Map to projections and aggregations (
SUMorMIN) to eliminate variables. - Join Nodes: Map to standard database joins and extended projections to combine independent sub-problems.
The authors implement this concept in a Python-based tool called dpdb, using PostgreSQL as the database backend. Instead of forcing users to write custom low-level code, dpdb provides a generalized template system where users specify problem-specific logic using declarative SQL snippets.
To maximize performance, dpdb operates directly on non-nice (arbitrary) tree decompositions to avoid table-copying overhead. It also structures queries using nested sub-queries rather than Common Table Expressions (CTEs), allowing the database optimizer to aggressively push down selections and minimize intermediate table sizes.
The relationship between a graph, its tree decomposition, and the resulting database table manipulations is illustrated in the paper's examples:
Datasets
The framework was evaluated using a total of 1,494 publicly available #SAT benchmark instances:
- fre/meel benchmarks: 1,480 instances.
- c2d benchmarks: 14 instances.
All instances were preprocessed using pmc, a state-of-the-art #SAT preprocessor. This preprocessing step is vital, as it successfully reduces the primal treewidth of more than 80% of these instances to a manageable width below 19.
Key Insights and Ideas
- Outsourcing to the Experts: Instead of reinventing the wheel for memory management, query optimization, and parallel execution,
dpdboutsources these tasks to a mature, production-grade relational database engine. - SQL as a Rapid Prototyping Language: Complex graph algorithms can be elegantly and compactly expressed via standard SQL queries (
SELECT,JOIN,GROUP BY). The authors demonstrate this versatility by implementing solvers for five distinct problems: #SAT, graph coloring (#o-COL), vertex cover (MINVC), MAXSAT, and independent dominating sets (MINIDS). - Sub-queries over CTEs: The choice of SQL syntax matters. In PostgreSQL, nested sub-queries perform significantly better than CTEs because they allow the query optimizer to push outer selections down into the sub-query, preventing massive intermediate data explosions.
Key Results
- Competitive Performance: In a rigorous evaluation against 14 other state-of-the-art specialized solvers,
dpdbachieved a solid second place overall, solving 1,233 instances (just behind the leading specialized solver,miniC2D, which solved 1,242). - Beating Specialized Tools:
dpdboutperformed several highly tuned, specialized knowledge compilation and CDCL-based solvers, includingd4,sharpSAT, andc2d. - Hardware Optimization: Moving from a traditional hard-disk setup (PostgreSQL 9.5) to PostgreSQL 12 running on a
tmpfsramdisk drastically reduced table-creation I/O overhead, unlocking the system's full performance potential.
Limitations and Future Work
- Table Creation Overhead: Creating and dropping database tables for every single node in a tree decomposition introduces a baseline latency overhead that hurts performance on very small or trivial instances.
- Lack of Indexing: Standard B*tree indices are too slow to construct on the fly for temporary dynamic programming tables, meaning
dpdbcurrently runs without database indices. - Future Directions: The authors plan to explore commercial database systems (like Oracle) to utilize enterprise features like bitmap indices, which could allow highly efficient bitwise operations across columns. They also plan to extend the framework to handle Quantified Boolean Formulas (QBF).
Summary updated