Overview
DuckDB is an embedded analytical database designed for OLAP (Online Analytical Processing) workloads. Often called “SQLite for analytics,” it excels at complex queries on large datasets. Zequel supports DuckDB through the official@duckdb/node-api driver (v1.4.4-r.1).
Supported Versions
- DuckDB 0.9+
- DuckDB 0.10+
- DuckDB 1.0+
- DuckDB 1.1+
- DuckDB 1.2+
Connection
File-Based Connection
DuckDB databases are single files:.duckdb.ddb.db
In-Memory Databases
Create temporary analytical databases:DuckDB’s in-memory mode is optimized for analytical queries and can handle larger datasets than SQLite’s in-memory mode.
Features
Tables & Views
- Create, drop, and rename tables
- Create and drop views (including CREATE OR REPLACE)
- View table metadata and statistics
Data Types
DuckDB supports rich analytical data types:- Numeric
- String
- Date/Time
- Complex Types
- Other
- TINYINT, SMALLINT, INTEGER, BIGINT
- HUGEINT (128-bit integers)
- UTINYINT, USMALLINT, UINTEGER, UBIGINT (unsigned)
- FLOAT, DOUBLE
- DECIMAL(precision, scale)
Indexes
- CREATE INDEX support
- Automatic index selection
- ART (Adaptive Radix Tree) indexes
DuckDB automatically creates and uses indexes for optimal query performance. Manual index creation is often unnecessary.
Constraints
- Primary keys
- Foreign keys (enforced)
- Unique constraints
- NOT NULL constraints
- CHECK constraints
Transactions
Full ACID transaction support:DuckDB-Specific Features
Analytical Functions
DuckDB excels at analytical SQL:Complex Type Support
Query nested and complex data:File Format Support
DuckDB can query many file formats directly:Extensions
DuckDB supports extensions for additional functionality:Query Optimization
DuckDB includes powerful optimization:- Columnar storage: Optimized for analytical queries
- Vectorized execution: Process data in batches
- Parallel execution: Automatic multi-threading
- Query plan caching: Reuse compiled queries
Performance Features
Streaming & Large Datasets
DuckDB can process datasets larger than RAM:- Out-of-core processing
- Streaming aggregations
- Spilling to disk when needed
Parallel Query Execution
Automatic parallelization:Query Cancellation
Zequel can interrupt long-running DuckDB queries using the driver’s interrupt mechanism.Limitations
Schema Limitations
- No ALTER COLUMN: Cannot modify column types
- Must recreate table with new schema
- No stored procedures or functions: DuckDB doesn’t support user-defined routines
- No triggers: Not supported in current versions
- No user management: File-based permissions only
Concurrency Limitations
- Single writer: One write transaction at a time
- Optimized for reads: Best for read-heavy analytical workloads
- Not designed for OLTP: Use PostgreSQL or MySQL for transactional workloads
Feature Limitations
- Cannot add foreign keys to existing tables
- Cannot add primary keys to existing tables
- Limited ALTER TABLE operations
Use Cases
Ideal For:
✅ Analytical queries on large datasets ✅ Data science and machine learning workflows ✅ Aggregations, joins, and window functions ✅ Querying Parquet, CSV, and JSON files ✅ Local data analysis ✅ ETL pipelines ✅ Embedded analytics in applicationsNot Ideal For:
❌ High-concurrency transactional workloads (OLTP) ❌ Real-time data ingestion ❌ Multi-user write scenarios ❌ Applications requiring stored proceduresBest Practices
-
Use appropriate data types
- Use INTEGER instead of VARCHAR for numbers
- Use DATE/TIMESTAMP for dates, not strings
-
Leverage columnar storage
- SELECT only columns you need
- Filter early in queries
-
Use Parquet for large datasets
-
Monitor memory usage
-
Analyze query plans
-
Use persistent databases for large datasets
- File-based storage is faster than in-memory for large data
File Associations
Zequel automatically associates with DuckDB files:.duckdb.ddb
Docker Development
Zequel includes a DuckDB seed database:- Tables with analytical data
- Complex data types (arrays, structs, maps)
- Views for common aggregations
- Sample analytical queries
Comparison with SQLite
| Feature | SQLite | DuckDB |
|---|---|---|
| Use Case | OLTP (transactions) | OLAP (analytics) |
| Performance | Fast for simple queries | Fast for complex aggregations |
| Complex Types | Limited | Rich (arrays, structs, maps) |
| File Formats | SQLite only | Parquet, CSV, JSON, etc. |
| Analytics | Basic | Advanced (window functions, etc.) |
| Concurrency | Good for reads | Optimized for read-heavy |
| Storage | Row-based | Column-based |