MongoDB vs DuckDB vs Redis for NGSI-LD
| Aspect | MongoDB | DuckDB | Redis |
|---|---|---|---|
| Type | Document store (NoSQL) | Analytical RDBMS (OLAP) | In-memory key-value store |
| Data Model | JSON/BSON documents | Columnar relational tables | Key-value, hashes, sets, sorted sets |
| Query Language | MQL | SQL (PostgreSQL dialect) | Commands + RediSearch |
| Architecture | Client-server | Embedded (in-process, like SQLite) | Client-server |
| Storage | Row-oriented on disk (BSON) | Columnar on disk | In-memory (optional persistence) |
| Best For | OLTP, flexible schemas | OLAP, analytics, batch | Caching, ultra-low-latency CRUD |
| Concurrency | Multi-user, multi-connection | Single-writer, multi-reader | Single-threaded event loop |
| Scaling | Horizontal (sharding) | Vertical only | Horizontal (Redis Cluster) |
| Transactions | Multi-document ACID | Full ACID | MULTI/EXEC (limited) |
| Joins | Limited ($lookup) | Full SQL joins | None |
| Memory | Configurable cache | Streams from disk | All data must fit in RAM |
| Footprint | ~500MB+ | ~20MB library | ~10MB binary |
| License | SSPL | MIT | RSALv2 + SSPLv1 |
| Workload | MongoDB | DuckDB | Redis |
|---|---|---|---|
| Point lookups by key | Fast (indexed) | Acceptable | Fastest (sub-ms) |
| Insert single records | Fast | Acceptable | Fastest (sub-ms) |
| Bulk inserts | Good | Very fast | Fast (pipelining) |
| Full table scans | Slow | Very fast (columnar) | Impractical at scale |
| Complex aggregations | Moderate | Very fast | Very limited |
| Joins | Slow ($lookup) | Very fast | Not supported |
| Concurrent writers | Excellent | Single writer | Single-threaded but fast |
| Geo queries | Good (2dsphere) | Limited | Good (GEOSEARCH) |
| Complex filtered queries | Good | Very fast | Limited (needs RediSearch) |
q parameter's nested attribute filters are hard to map| Role | Best Candidate | Rationale |
|---|---|---|
| Current state (simple access) | Redis | Fastest CRUD by entity ID |
| Current state (complex queries) | MongoDB | Rich query engine for q filters |
| Current state (hybrid) | Redis + MongoDB/DuckDB | Speed + query power + durability |
| Temporal / TRoE | DuckDB or TimescaleDB | Analytical queries over time-series data |
The ideal FiWorks NGSI-LD Broker database architecture is not a single technology choice but a layered approach:
q-filter support beyond what Redis offersDuckDB's embedded nature (in-process, like SQLite) is particularly interesting — it eliminates the network roundtrip to a database server entirely, which aligns perfectly with the C broker's performance-first philosophy.