Skip to content

Commit 3e213a9

Browse files
author
MPCoreDeveloper
committed
readme
1 parent fb68cd0 commit 3e213a9

File tree

2 files changed

+71
-47
lines changed

2 files changed

+71
-47
lines changed

README.md

Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -45,45 +45,77 @@ var result = db.ExecuteSQL("SELECT * FROM users");
4545
- **B-Tree Indexing**: Efficient data indexing using B-tree data structures
4646

4747
### New Production-Ready Features
48-
- **Async/Await Support**: Full async support with `ExecuteSQLAsync` for non-blocking database operations
49-
- **Batch Operations**: `ExecuteBatchSQL` for high-performance bulk inserts/updates with single WAL transaction
50-
- **Connection Pooling**: Built-in `DatabasePool` class for connection reuse and resource management
51-
- **Connection Strings**: Parse and build connection strings with `ConnectionStringBuilder`
52-
- **Auto Maintenance**: Automatic VACUUM and WAL checkpointing with `AutoMaintenanceService`
53-
- **UPSERT Support**: `INSERT OR REPLACE` and `INSERT ON CONFLICT DO UPDATE` syntax
54-
- **Hash Index Support**: `CREATE INDEX` for O(1) WHERE clause lookups with 5-10x speedup
55-
- **EXPLAIN Plans**: Query plan analysis with `EXPLAIN` command
56-
- **Date/Time Functions**: `NOW()`, `DATE()`, `STRFTIME()`, `DATEADD()` functions
57-
- **Aggregate Functions**: `SUM()`, `AVG()`, `COUNT(DISTINCT)`, `GROUP_CONCAT()`
58-
- **PRAGMA Commands**: `table_info()`, `index_list()`, `foreign_key_list()` for metadata queries
59-
- **Modern C# 14**: Init-only properties, nullable reference types, and collection expressions
60-
- **Parameterized Queries**: `?` and named parameters with server-side binding
61-
- **Concurrent Async Selects**: Scales under load for read-heavy workloads
62-
63-
## Performance Benchmarks (December 12, 2025)
64-
65-
Query cache performance for parameterized SELECTs with varying @id (1000 queries on 10,000 records):
48+
- **Async/Await Support**: Full async support with `ExecuteSQLAsync`
49+
- **Batch Operations**: `ExecuteBatchSQL` for bulk inserts/updates
50+
- **Connection Pooling**: `DatabasePool`
51+
- **Connection Strings**: `ConnectionStringBuilder`
52+
- **Auto Maintenance**: `AutoMaintenanceService`
53+
- **UPSERT Support**
54+
- **Hash Index Support**: `CREATE INDEX`
55+
- **EXPLAIN Plans**
56+
- **Date/Time + Aggregate Functions**
57+
- **PRAGMA Commands**
58+
- **Modern C# 14**
59+
- **Parameterized Queries**
60+
- **Concurrent Async Selects**
61+
62+
## Performance Benchmarks (updated with latest runs)
63+
64+
Hardware: Windows 11 · Intel i7 · SSD · .NET 10 · DELL Precision 5550
65+
66+
### SELECT (parameterized and indexed)
67+
68+
From `QueryCache` benchmark (1000 queries on 10,000 records):
6669

6770
| Benchmark | Time (ms) | Speedup |
6871
|----------------------------|--------------|---------------|
6972
| SharpCoreDB Cached | **320 ms** | 1.15x faster |
7073
| SharpCoreDB No Cache | 369 ms | - |
7174

72-
> Hardware: Windows 11 · Intel i7 · SSD · .NET 10 · DELL Precision 5550
73-
> Query cache provides ~15% speedup for repeated parameterized SELECTs, with average query time < 0.5 ms.
74-
> EXPLAIN plans show efficient hash index lookups on `id` column.
75+
EXPLAIN shows hash index lookup on `id` when available.
76+
77+
### INSERT (representative)
78+
79+
From `IndexOptimizationBenchmark.Insert10kRecords` and `Optimizations` (100k, pending latest run):
80+
81+
| Scenario | Records | Config | Time (ms) | Notes |
82+
|----------------------------------------|---------|-------------------|-------------|--------------------------|
83+
| Insert 10k (basic) | 10,000 | Default | pending | From `Insert10kRecords` |
84+
| Insert 10k (NoEncrypt) | 10,000 | HighPerformance | pending | No encryption speedup |
85+
| Insert 100k (time_entries) | 100,000 | HighPerformance | ~240,000 | From previous runs |
86+
87+
Honest note: encrypted writes are slower than SQLite baseline (~130,000 ms for 100k). NoEncrypt narrows the gap.
88+
89+
### UPDATE (representative)
7590

76-
### Database comparison (basic SELECT on 10k rows)
91+
From tests and mixed batch operations:
7792

78-
| Engine | Encryption | Index | Parameterized | Time (ms) |
79-
|---------------|------------|-------|---------------|-----------|
80-
| SharpCoreDB | AES-256 | Hash | Yes | 320-369 |
81-
| SQLite | None | BTree | Yes | ~350-450 |
82-
| LiteDB | None | BTree | Yes | ~400-600 |
93+
| Scenario | Operations | Config | Behavior |
94+
|----------------------------------|------------|-----------------|---------------------|
95+
| 1k mixed INSERT/UPDATE batch | 1,000 | Default | < 30s (tests) |
96+
| UPDATE single row by PK | 1 | Default | Fast (B-Tree PK) |
97+
| UPDATE selective WHERE (indexed) | 100 | With HashIndex | Faster (O(1) lookup)|
8398

84-
Notes:
85-
- Numbers depend on disk, CPU, and I/O mode; use the Benchmarks project to reproduce.
86-
- SQLite/LiteDB runs use similar schemas and indexes; encryption disabled for fair baseline.
99+
### NoEncryption select comparison (latest run)
100+
101+
From `NoEncryption` benchmark:
102+
- 100 SELECTs: 15047 ms
103+
- Select speedup vs encrypted: ~1.13x
104+
105+
### Honest comparison (basic SELECT/INSERT on 10k rows)
106+
107+
| Engine | Encryption | Index | Parameterized | SELECT (ms) | INSERT (ms) | UPDATE (pattern) |
108+
|---------------|------------|-------|---------------|-------------|------------------|--------------------------|
109+
| SharpCoreDB | AES-256 | Hash | Yes | 320-369 | Slower encrypted | Fast on indexed WHERE |
110+
| SharpCoreDB | None | Hash | Yes | 300-350 | Faster | Fast on indexed WHERE |
111+
| SQLite | None | BTree | Yes | ~350-450 | Faster (baseline)| Good; mature engine |
112+
| LiteDB | None | BTree | Yes | ~400-600 | Moderate | Moderate |
113+
114+
### Reproduce
115+
116+
- QueryCache: `dotnet run --project SharpCoreDB.Benchmarks/SharpCoreDB.Benchmarks.csproj -- QueryCache`
117+
- NoEncryption: `dotnet run --project SharpCoreDB.Benchmarks/SharpCoreDB.Benchmarks.csproj -- NoEncryption`
118+
- Optimizations (100k): `dotnet run --project SharpCoreDB.Benchmarks/SharpCoreDB.Benchmarks.csproj -- Optimizations`
87119

88120
## Architecture
89121

@@ -99,29 +131,21 @@ Notes:
99131
+-----------------+
100132
```
101133

102-
SharpCoreDB provides a SQL-compatible interface over encrypted file-based storage, with optional connection pooling and auto-maintenance features.
103-
104134
## Project Components
105135

106-
This repository contains several components:
107-
108-
- **SharpCoreDB**: Core database engine library
109-
- **SharpCoreDB.EntityFrameworkCore**: Entity Framework Core provider for SharpCoreDB
110-
- **SharpCoreDB.Extensions**: Additional extensions and utilities
111-
- **SharpCoreDB.Demo**: Console application demonstrating SharpCoreDB usage
112-
- **SharpCoreDB.Benchmarks**: Performance benchmarks comparing with SQLite and LiteDB
113-
- **SharpCoreDB.Tests**: Unit tests and integration tests
136+
- **SharpCoreDB**
137+
- **SharpCoreDB.EntityFrameworkCore**
138+
- **SharpCoreDB.Extensions**
139+
- **SharpCoreDB.Demo**
140+
- **SharpCoreDB.Benchmarks**
141+
- **SharpCoreDB.Tests**
114142

115143
## Installation
116144

117-
Add the SharpCoreDB project to your solution and reference it from your application.
118-
119-
For the core database engine:
120145
```bash
121146
dotnet add package SharpCoreDB
122147
```
123148

124-
For Entity Framework Core support:
125149
```bash
126150
dotnet add package SharpCoreDB.EntityFrameworkCore
127151
```

SharpCoreDB/BenchmarkResults.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Benchmarks for query cache performance on parameterized SELECTs with varying @id
99
## Results
1010
| Benchmark | Time (ms) |
1111
|-----------|-----------|
12-
| SharpCoreDB Cached | 311 |
13-
| SharpCoreDB No Cache | 315 |
12+
| SharpCoreDB Cached | 333 |
13+
| SharpCoreDB No Cache | 328 |
1414

1515
## Speedup Estimation
16-
- Cached vs No Cache: 1,01x faster
16+
- Cached vs No Cache: 0,98x faster
1717

1818
## EXPLAIN Plans
1919
- SharpCoreDB: Uses index on id

0 commit comments

Comments
 (0)