DecidB - DuckDB with DECIDE clause for optimization queries
Project description
DeciDB
Optimization, Native in SQL
DeciDB extends SQL with the DECIDE clause for declarative in-database optimization. Express Integer Linear Programming (ILP) problems directly in SQL — no external solvers, no data export, no context switching.
A research project by HUDA Lab at NYU Abu Dhabi.
Quick Example
Traditional approach — export data, build a model in Python, solve, map results back:
import duckdb, pulp
items = conn.execute("SELECT id, value, weight FROM Items").fetchall()
prob = pulp.LpProblem("knapsack", pulp.LpMaximize)
x = [pulp.LpVariable(f"x_{i}", cat='Binary') for i in range(len(items))]
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()
# ... then map results back to database
With DeciDB — one SQL query:
SELECT id, value, weight, x
FROM Items
WHERE category = 'electronics'
DECIDE x IS BOOLEAN
SUCH THAT
SUM(x * weight) <= 50
MAXIMIZE SUM(x * value);
Same result, a fraction of the code.
Installation
pip install decidb
Usage
import decidb
# Connect (in-memory or file-based)
conn = decidb.connect()
# Create data
conn.execute("""
CREATE TABLE Items (id INTEGER, value INTEGER, weight INTEGER);
INSERT INTO Items VALUES (1, 100, 20), (2, 60, 10), (3, 120, 30);
""")
# Run an optimization query
result = conn.execute("""
SELECT id, value, weight, x
FROM Items
DECIDE x IS BOOLEAN
SUCH THAT
SUM(x * weight) <= 50
MAXIMIZE SUM(x * value)
""").fetchall()
print(result)
The DECIDE Clause
DeciDB adds the DECIDE clause to standard SQL:
SELECT columns
FROM table
DECIDE variable [IS type], ...
SUCH THAT
constraint AND ...
MAXIMIZE | MINIMIZE SUM(objective)
Decision Variable Types
| Type | Domain | Example |
|---|---|---|
IS BOOLEAN |
{0, 1} | Select/skip an item |
IS INTEGER |
{0, 1, 2, ...} | Quantity to assign |
IS INTEGER is the default if no type is specified.
Constraints
- Arithmetic:
SUM(x * weight) <= 50 - Multiple constraints separated by
AND - Conditional constraints:
SUM(x * weight) <= 50 WHEN category = 'A' - Supported operators:
=,<>,<,<=,>,>=
Objective
MAXIMIZE SUM(x * value)
MINIMIZE SUM(x * cost)
All expressions involving decision variables must be linear.
Use Cases
- Knapsack / inventory selection — maximize value under weight or budget constraints
- Portfolio optimization — select assets maximizing return under risk limits
- Resource allocation — assign resources to tasks within capacity constraints
- Meal planning — choose items optimizing nutrition within calorie budgets
Key Features
- Native SQL — no context switching between query and optimization languages
- Zero data movement — solve directly on database buffers
- Declarative — define what to optimize, not how
- Embedded solver — powered by HiGHS, a high-performance LP/MIP solver
Documentation
Research
DeciDB builds on a decade of research into in-database constrained optimization:
- Scalable Package Queries in Relational Database Systems — Brucato, Abouzied, Meliou (VLDB 2016)
- Scalable Computation of High-Order Optimization Queries — Brucato, Abouzied, Meliou (CACM 2019)
- Scaling Package Queries to a Billion Tuples — Mai, Wang, Abouzied, Brucato, Haas, Meliou (VLDB 2024)
License
MIT License. See LICENSE for details.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file decidb-0.1.0.tar.gz.
File metadata
- Download URL: decidb-0.1.0.tar.gz
- Upload date:
- Size: 12.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
114e33c9aab618c0369ebd7a3885e0691c0249e61d7311504e6bf99d27c6765a
|
|
| MD5 |
3632a7abbf40a09e291cebcf22d216b9
|
|
| BLAKE2b-256 |
797276763b2fbbb58ba07579b1ee3d7d1dab1d1d2aad88daee27a64b7cd13ba2
|
Provenance
The following attestation bundles were made for decidb-0.1.0.tar.gz:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0.tar.gz -
Subject digest:
114e33c9aab618c0369ebd7a3885e0691c0249e61d7311504e6bf99d27c6765a - Sigstore transparency entry: 1711827743
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: decidb-0.1.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deaecd0c5dd984a185983be09f2bd99d7af2dcbdfc50ddd3cdbabb7a2fb5bb35
|
|
| MD5 |
ef2fce7f28759d62036be4301c82d902
|
|
| BLAKE2b-256 |
8c8762f106d8a1885c1916108f88a13a02ba22ed5e689700e103c789af63278e
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp313-cp313-win_amd64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp313-cp313-win_amd64.whl -
Subject digest:
deaecd0c5dd984a185983be09f2bd99d7af2dcbdfc50ddd3cdbabb7a2fb5bb35 - Sigstore transparency entry: 1711827763
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: decidb-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.0 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af1de0594b3769d24b1bbafc90a229af0729d50d2cf1e21a1cf7f9f47c9492a2
|
|
| MD5 |
8d72bb8dfd7f534500335e208dfd21e1
|
|
| BLAKE2b-256 |
f464d874333630a2361874fbae35b9804f444fb61e572eff4523298a28b1c5f4
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
af1de0594b3769d24b1bbafc90a229af0729d50d2cf1e21a1cf7f9f47c9492a2 - Sigstore transparency entry: 1711827827
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: decidb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 32.3 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
820bea874934a980d28120278ed05449b8e91e3f3fad775f2bf45954fa9d8457
|
|
| MD5 |
f3ee63b47f3b7cca082d6874da7a401f
|
|
| BLAKE2b-256 |
366c28c24467ca3fab6103950914122ad1f032a77761eec9a2c5b6305bf45c14
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
820bea874934a980d28120278ed05449b8e91e3f3fad775f2bf45954fa9d8457 - Sigstore transparency entry: 1711827840
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: decidb-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bd5b6036ada50e1d52ea68ddc55141cec0676ad082667640d97b087dc66daac
|
|
| MD5 |
f5af91a6ad7fd59360a4590dc767621f
|
|
| BLAKE2b-256 |
b1ac661d93a971da56bb09c3d0a5f655c0130ac71c708fe6dc5f35c408706ddc
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp312-cp312-win_amd64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp312-cp312-win_amd64.whl -
Subject digest:
3bd5b6036ada50e1d52ea68ddc55141cec0676ad082667640d97b087dc66daac - Sigstore transparency entry: 1711827782
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: decidb-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9851f48aca3f03e3bf282a004595f3c75bf7d82f99dd04beea9f195cf990c30c
|
|
| MD5 |
b79b43b0712ae8cbba5e80ffea12f180
|
|
| BLAKE2b-256 |
0ddd2850bc1269db3174469c6b140fea9b42bbbbe603f8099a1897ba5c87a331
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
9851f48aca3f03e3bf282a004595f3c75bf7d82f99dd04beea9f195cf990c30c - Sigstore transparency entry: 1711827789
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: decidb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 32.3 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1e475573980128dd4c6836d7e736f1fec88b5d4fd2a483211ee35910ffc6f52
|
|
| MD5 |
4d088d605ff54fb5c9cce8d9f96d6d4d
|
|
| BLAKE2b-256 |
f3fb5c66a257f4f657d1a005f29c226c98e63e4f2ecd63ef5da34933db7cee44
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
d1e475573980128dd4c6836d7e736f1fec88b5d4fd2a483211ee35910ffc6f52 - Sigstore transparency entry: 1711827755
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: decidb-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1f40d5895d42bc8b2c52f618e26750d139039e6ffd1c2a334e0dac744670546
|
|
| MD5 |
ee4760e5442fe199bd1a0d0cdf1a1eb2
|
|
| BLAKE2b-256 |
b639ff7a76a85ad3d43da104c632f2ac2dadc2782fa0140f65c85c23af2d526d
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp311-cp311-win_amd64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp311-cp311-win_amd64.whl -
Subject digest:
c1f40d5895d42bc8b2c52f618e26750d139039e6ffd1c2a334e0dac744670546 - Sigstore transparency entry: 1711827776
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: decidb-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f97185bf936cbaa84a28ee6089ab6cb89c1fc05b4362ff60ee7f68a04d5c41ef
|
|
| MD5 |
2ea852711bc99f0c55898e381420c6c0
|
|
| BLAKE2b-256 |
59567363931336861af9d1ccf5f70ddbf164b9e42c3ad2fd3400c11926563045
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
f97185bf936cbaa84a28ee6089ab6cb89c1fc05b4362ff60ee7f68a04d5c41ef - Sigstore transparency entry: 1711827769
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decidb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: decidb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 32.3 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6e89a5445f06c1178e052432af6bb992c75df0ef3f5f8f349d52f1a5139959b
|
|
| MD5 |
c8515c1bd703e2001f46a9f72dee1954
|
|
| BLAKE2b-256 |
59cd813be09cdb4b37443118f66c37169cc7d74f6ddd3df91069ca880b9b9592
|
Provenance
The following attestation bundles were made for decidb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
python-wheels.yml on huda-lab/decidb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decidb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
e6e89a5445f06c1178e052432af6bb992c75df0ef3f5f8f349d52f1a5139959b - Sigstore transparency entry: 1711827806
- Sigstore integration time:
-
Permalink:
huda-lab/decidb@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/huda-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@02fea0d02c222a6354e41efc9163b082b24b34b7 -
Trigger Event:
release
-
Statement type: