Optimization, Native in SQL
DeciDB extends DuckDB with declarative optimization. Assign optimal decisions over data with constraints and objectives — no external solver code required.
SELECT item, value, weight, x AS selected
FROM Items
DECIDE x(BOOL)
SUCH THAT
SUM(x * weight) <= 50
MAXIMIZE SUM(x * value);
One query. No data export. No solver code. Just SQL.
Why Optimization Belongs in the Database
Many real-world decisions require choosing or allocating over rows in a table — which products to stock, which patients to schedule, how much to ship. Today, solving these decision problems means exporting data, writing solver code in Python, and mapping results back. DeciDB collapses that entire pipeline into a single SQL statement.
# Step 1: Export data from database
import duckdb, pulp
conn = duckdb.connect('db.duckdb')
items = conn.execute("""
SELECT id, value, weight FROM Items
WHERE category = 'electronics'
""").fetchall()
# Step 2: Build optimization model
prob = pulp.LpProblem("knapsack", pulp.LpMaximize)
x = [pulp.LpVariable(f"x_{i}", cat='Binary')
for i in range(len(items))]
# Step 3: Add constraints + solve
prob += pulp.lpSum(
x[i] * items[i][2] for i in range(len(items))
) <= 50
prob += pulp.lpSum(
x[i] * items[i][1] for i in range(len(items))
)
prob.solve()
# Step 4: Map results back to database...
-- One query does it all
SELECT id, value, weight, x
FROM Items
WHERE category = 'electronics'
DECIDE x(BOOL)
SUCH THAT
SUM(x * weight) <= 50
MAXIMIZE SUM(x * value);
Same result, a fraction of the code. No context switching between languages.
Built for Complex Selection Problems
Selection, assignment and allocation problems can all be expressed with typed decision variables and collective constraints.
Why DeciDB?
Native SQL
Express optimization as a SQL extension. No context switching.
Zero Data Movement
Solve directly on database buffers. No export/import overhead.
Declarative
Define what to optimize, not how. The system handles formulation.
Built on DuckDB
Columnar storage, vectorized execution, and runtime selection between Gurobi and bundled HiGHS.