Files anyone can open
Data kept in standard SQLite files: other programs open Phai SQL's files, and Phai SQL opens theirs
Phai SQL is written in Rust from the ground up. It reads and writes SQLite files both ways, encrypts them, lets an AI use your data without seeing ID numbers, phone numbers or salaries, and runs as a server for the office's programs. No cloud service needed.
Each checked statement by statement to give the same results, error messages and file as the reference
Data kept in standard SQLite files: other programs open Phai SQL's files, and Phai SQL opens theirs
Every kind of JOIN, subqueries, WITH and WITH RECURSIVE, window functions, UPSERT, RETURNING, views, triggers, JSON and JSON5, date functions
AES-256 and HMAC-SHA512 in SQLCipher 4's format; a password for each person, a recovery key, re-keying
An AI only reads; private columns come masked (081*****78) and can't be used to guess; row and time limits; every statement logged
Embeddings in ordinary tables, nearest-meaning search, and the way to RAG with Phai AI
COLLATE THAI: Thai dictionary order (a leading vowel sorts by the consonant after it); a Thai guide and messages
Speaks MySQL's protocol: phpMyAdmin, PHP (mysqli, PDO), mysql and mysqldump work; users and rights; TLS
Transactions, savepoints, rollback-journal and WAL modes, many readers at once, the file shared with other programs through the same locks
Written from the specifications, wrapping nobody's code; cryptography from RustCrypto; a library in Rust programs or a server
Every number measured, with its source and limits in the project's documents
files of the standard SQL test suite pass: 5,729,093 queries and 210,786 statements, 0 wrong
a cut simulated at every step of a commit (half-written pages too), plain, WAL and encrypted: the file is always as before or after
fuzzed with random bytes: a damaged file gets the answer "damaged", never a hang or a crash
Measured on one machine on 3 December 2026, every engine set up alike: where Phai SQL is faster and where it is still slower
The same file, an 8 MB page cache each, milliseconds (best of 3, measured twice)
| Task | Phai SQL | SQLite | |
|---|---|---|---|
| Look up by id | 0.03 | 0.05 | 1.7–2× faster |
| Look up by an indexed name | 0.02 | 0.05 | 1.7–2.5× faster |
| A range of names (index range) | 4.11 | 3.72 | about even |
| The first screen of 50 | 0.06 | 0.14 | 2.3–2.6× faster |
| Jump to the middle | 0.06 | 0.14 | 2.3–2.5× faster |
| count(*) of the whole table | 519 | 141 | 3.7× slower |
| sum and avg over all | 427 | 895 | 1.8–2.1× faster |
| A filter with no index | 453 | 699 | 1.5× faster |
| Group by month | 1,782 | 6,668 | 3.7–4× faster |
| Sort with no index (top 10) | 361 | 846 | 2.4× faster |
An 8 MB cache each, every commit flushed to disk, seconds (best of 2 pairs; the comparison is the range over the pairs)
| Task | Phai SQL | SQLite | |
|---|---|---|---|
| Insert 10 million rows | 152.8 | 224.3 | 1.2–1.5× faster |
| UPDATE a tenth | 16.6 | 29.6 | 1.5–2.3× faster |
| DELETE a tenth | 7.4 | 21.3 | 2.6–4× faster |
| Peak RAM (MB) | 26 | 16–20 | 1.3–1.6× more |
PHP 8.2 mysqli over TCP, 100,000 rows, MySQL as it comes (128 MB buffer pool, every commit flushed), seconds (best of 3 rounds; the comparison is the range over the rounds)
| Task | Phai SQL | MySQL | |
|---|---|---|---|
| Insert in one transaction | 10.37 | 10.97 | 1.1–1.5× faster |
| 500 single-row commits | 0.159 | 0.183 | about even |
| 20,000 lookups by id | 1.76 | 2.40 | 1.4–1.5× faster |
| 5,000 lookups by index | 0.478 | 0.804 | 1.7–2.4× faster |
| count, sum, avg ×5 | 0.020 | 0.099 | 3.9–6.1× faster |
| GROUP BY ×5 | 0.088 | 0.312 | 2.9–4.1× faster |
| Read every row | 0.137 | 0.125 | 5–13% slower |
| UPDATE every row | 0.044 | 0.287 | 4.7–9.4× faster |
| DELETE half | 0.187 | 0.320 | 1.7–1.8× faster |
| Peak memory (MB) | 26.9 | 38.6 | 30% less |
Where it is still slower, we will make it better: count(*) of a whole table (the cause is found), reading every row through the server, index ranges, and RAM while writing, still above SQLite's. Each time it improves, it is measured again and shown here as it is.
The machine: Intel Core Ultra 7 155H, 32 GB RAM, NVMe SSD, Windows 11. The raw numbers, the commands and every limit are in the project's documents (docs/facts.md).
Phai SQL is the retrieval half of RAG: it keeps the documents and vectors, searches by meaning, and decides who may find what; private data is masked before any AI sees it. Paired with Phai AI (in the making), you get an AI that answers from your own data, on your own machine, with nothing sent away.
An SQL guide in Thai and English, 36 chapters from the first SELECT to window functions, triggers, JSON and Thai text, on a practice shop. Every example is run and its result checked before the site is built.
One file, nothing else to install
Download and unpack phai-sql-0.1.0-windows-x64.zip: you get phai-sql-server.exe
Set a password the first time: phai-sql-server.exe D:\data --set-password admin
Start it: phai-sql-server.exe D:\data --listen 127.0.0.1:3306, then connect with Phai Database Studio, phpMyAdmin or PHP
Each .phdb file in the folder is one database. By default it listens on this machine only; never open it to the internet, use a VPN for other machines.
A preview: for test data, or data you have backed up. 1.0 brings a Windows service, a shell program and a Linux build.
phai-sql-0.1.0-windows-x64.zipa50580689549ede374dd5253fe11c30ea16e1fe4e41a562c738cc652dbc5fc132 downloads · 2026-12-02