FlexQL is a custom-built, high-concurrency relational database engine written in C++14. It is designed to handle massive datasets (up to 20M+ rows) with a focus on low-latency insertion and efficient memory management.
- Async Disk I/O: Decoupled RAM updates from physical disk writes using a background worker thread with backpressure support.
- Multithreaded Architecture: Fixed-size Thread Pool for connection handling and
shared_timed_mutexfor concurrent Read/Write operations. - Advanced Caching: LRU (Least Recently Used) cache to accelerate frequent queries.
- O(1) Indexing: Primary Hash Index using
std::unordered_mapfor instant record lookups. - Memory Purging: Background maintenance thread for automatic purging of expired TTL records.
FlexQL enforces strict typing (INT, DECIMAL, VARCHAR, DATETIME) and focuses on a streamlined, high-performance subset of relational operations:
- Data Definition (DDL): Dynamic table creation with strongly typed schemas.
- Data Manipulation (DML): High-throughput row insertions with support for mandatory expiration timestamps (TTL).
- Querying & Projection: Fetch entire tables or project specific columns to minimize memory overhead.
- Filtering: Single-condition
WHEREclause evaluation. - Relational Joins:
INNER JOINoperations with dynamicONclause parsing and optional post-join filtering.
- OS: Ubuntu 20.04+ (or any modern Linux distro)
- Compiler:
g++(supporting C++14) - Libraries: POSIX Threads (
pthread), Standard Template Library (STL)
Clone the repository and navigate into the project directory:
git clone https://github.com/DigvijayPatil12/flexql.git
cd flexqlFrom the root directory, run the following commands to build the system:
g++ -std=c++14 -pthread -O3 -I./include src/server/server.cpp -o bin/flexql-serverg++ -std=c++14 -I./include src/client/flexql_client.cpp src/client/main.cpp -o bin/flexql-clientg++ -std=c++14 -O3 -I./include src/client/flexql_client.cpp tests/benchmark_flexql.cpp -o bin/run-benchmarkOpen multiple terminal windows to run the server and clients concurrently.
1. Start the Server:
./bin/flexql-server2. Run Interactive SQL (in a new terminal):
./bin/flexql-client3. Run the Benchmark (in a new terminal): You can specify the exact number of rows to insert (e.g., 10 Million):
./bin/run-benchmark 100000004. Run Unit Tests: To verify the internal data structures and SQL operations without running the massive benchmark:
./bin/run-benchmark --unit-testFlexQL achieves a sustained throughput of ~500,000 rows/second on standard hardware by utilizing 5000-row batching and asynchronous persistence. Detailed performance metrics, cache hit ratios, and scalability plots are available in the project design document.