# Introducing Tern Db (in Gossamer)

After working on this privately for a while, I'm ready to share [Tern Db](https://github.com/danpozmanter/terndb). Built in 100% [Gossamer](https://github.com/gossamer-lang/gossamer), Tern Db is an embedded key value store with SQL syntax on top of it.

I built it to be read optimized and gentle on RAM and CPU demands, in service of a FOSS content management system I'm building in Gossamer aimed at a particular group of users who want a self hosted blog with a good user experience.

Raw query performance was excellent:

![](https://cdn.hashnode.com/uploads/covers/61ee32fec99aed184e725fac/135c2a21-cc0f-4f37-9a1c-db24ef5517d7.png align="center")

After iterating (and looking for reference implementations and other sources of ideas to optimize - I improved it further:

![](https://cdn.hashnode.com/uploads/covers/61ee32fec99aed184e725fac/5b33ae71-81a5-4a7a-983f-4db11e16bede.png align="center")

Tern DB went from 3.4 million queries/s to 12.1 million. (Rust's Redb from 2.46 to 2.49 million, and Rust with SQLite from 656k to 674k).

RAM usage is reasonable:

![](https://cdn.hashnode.com/uploads/covers/61ee32fec99aed184e725fac/bb70dfaf-6054-4401-b2c4-3dd99809625a.png align="center")

Within an HTTP server we can see the use case Tern DB was built for - running a lightweight web service on a small VPS. Let's look at CPU, Memory, and Requests/Sec:

![](https://cdn.hashnode.com/uploads/covers/61ee32fec99aed184e725fac/bcf8863b-7bbb-4fb0-ab00-325c6a7883e9.png align="center")

![](https://cdn.hashnode.com/uploads/covers/61ee32fec99aed184e725fac/dae910df-31d4-4862-8492-b5a466ec0df5.png align="center")

![](https://cdn.hashnode.com/uploads/covers/61ee32fec99aed184e725fac/e6503e14-6f03-4fda-bfae-829cf738a080.png align="center")

If you want to build a small self hosted site with an embedded database, Gossamer is shaping into an excellent option with Tern's help.
