Quick Start
How Redis Works
Redis is key-value, not relational. It cannot filter data natively like SQL databases.| Database | WHERE Filtering |
|---|---|
| PostgreSQL | Native (database does it) |
| MySQL | Native (database does it) |
| MongoDB | Native (database does it) |
| Redis | OmniQL handles it in Go |
Data Model
OmniQL maps entities to Redis Hash structures:| Concept | OmniQL | Redis |
|---|---|---|
| Entity | User | Hash keys with prefix |
| Record | User WHERE id = 1 | HGETALL tenant:user:1 |
| Field | name, email | Hash fields |
Key Pattern
Query Types
Direct Key Lookup (Fast)
When you query byid, OmniQL translates directly to Redis commands:
Filtered Query (Scan + Filter)
When you query by other fields, OmniQL scans keys and filters results:CRUD Operations
GET (HGETALL)
By ID (direct lookup):CREATE (HMSET)
UPDATE (HSET)
DELETE (DEL)
BULK INSERT
UPSERT
DROP TABLE
Filtering Support
OmniQL supports all standard operators for Redis filtering:| Operator | Example | Supported |
|---|---|---|
= | status = "active" | ✅ |
!= | status != "banned" | ✅ |
> | age > 21 | ✅ |
< | age < 65 | ✅ |
>= | score >= 100 | ✅ |
<= | price <= 50 | ✅ |
IN | status IN ("active", "pending") | ✅ |
NOT IN | role NOT IN ("admin", "mod") | ✅ |
BETWEEN | age BETWEEN 18 AND 65 | ✅ |
LIKE | name LIKE "John%" | ✅ |
IS NULL | deleted_at IS NULL | ✅ |
IS NOT NULL | email IS NOT NULL | ✅ |
AND | age > 21 AND active = true | ✅ |
OR | status = "active" OR role = "admin" | ✅ |
Example with Complex Filter
Aggregations
OmniQL provides aggregation operations:COUNT
SUM
AVG
MIN / MAX
Transactions
Redis supports transactions with MULTI/EXEC:Note:DISCARDcancels the transaction before execution. OnceEXECruns, changes cannot be rolled back.
Permissions (ACL)
Redis uses ACL for user management:CREATE USER
GRANT
REVOKE
DROP USER
Note: Redis has users with permissions, not roles.CREATE ROLE,DROP ROLE,ASSIGN ROLEare not supported.
Type Storage
All Redis values are stored as strings:| OmniQL Type | Redis Storage |
|---|---|
STRING | String |
INT | String (“42”) |
BOOLEAN | String (“true”/“false”) |
TIMESTAMP | String (ISO format) |
JSON | String (serialized) |
UUID | String |
Supported Operations
| Operation | Supported | Notes |
|---|---|---|
| GET | ✅ | HGETALL |
| CREATE | ✅ | HMSET |
| UPDATE | ✅ | HSET |
| DELETE | ✅ | DEL |
| UPSERT | ✅ | HMSET |
| BULK INSERT | ✅ | Multiple HMSET |
| DROP TABLE | ✅ | DEL pattern |
| COUNT | ✅ | Via OmniQL |
| SUM / AVG / MIN / MAX | ✅ | Via OmniQL |
| WHERE (all operators) | ✅ | Via OmniQL filtering |
| ORDER BY | ✅ | Via OmniQL |
| LIMIT / OFFSET | ✅ | Via OmniQL |
| BEGIN / COMMIT | ✅ | MULTI / EXEC |
| ROLLBACK | ✅ | DISCARD |
| CREATE USER | ✅ | ACL SETUSER |
| GRANT / REVOKE | ✅ | ACL SETUSER |
Not Supported
| Feature | Reason |
|---|---|
| JOIN | Key-value model has no relations |
| GROUP BY / HAVING | Use aggregations instead |
| Window functions | No SQL semantics |
| SAVEPOINT | Redis has no partial rollback |
| Roles | Redis has users only, not roles |
Performance Considerations
| Query Type | Performance | When to Use |
|---|---|---|
WHERE id = X | ⚡ Instant | Always preferred |
WHERE field = X LIMIT N | 🔄 Scan + filter | Small datasets, with LIMIT |
WHERE field = X (no limit) | ⚠️ Full scan | Avoid on large datasets |
Best Practices
- Use ID lookups when possible - Direct key access is instant
- Always use LIMIT - Prevents scanning entire keyspace
- Index hot queries in SQL - For complex filtering, consider PostgreSQL
- Use Redis for what it’s good at - Sessions, caching, counters, real-time data
When to Use Redis with OmniQL
Good use cases:- Session storage
- User profiles / settings
- Caching layer
- Real-time counters
- Simple CRUD by ID
- Aggregations on bounded datasets
- Complex queries with multiple filters
- Relational data with joins
- Large datasets requiring full scans
- Data requiring GROUP BY

