If I were to write my own client and server software, which database would be better? Using native_db which integrates with Rust with your structures or using something like rust-postgres?
It's up to you. I started using rusqlite
over a year ago for an HTTP server and it works great for me.
I haven't heard of native_db
before...
But the benchmarks are kind of suspicious: native_db/benches/setup.rs at 455c0eca047bd628e744660588492fdf9d93ac15 · vincent-herlemont/native_db · GitHub ...
If you're going to benchmark against sqlite competitively, you should be enabling (at minimum) write-ahead logging. I understand that tuning sqlite requires a lot of care, but its importance cannot be overstated. The defaults have surprisingly poor performance.
I was able to get very simple INSERT
/UPDATE
query times down from 8ms to 0.1ms with WAL and synchronous = NORMAL
(reducing fsync
overhead to sacrifice some durability in exchange for fast response times). You may not be comfortable with this tradeoff, but in my case it was worth it.
See also this recent conversation and the linked article: SQLite or PostgreSQL? It's Complicated | Lobsters
I will keep this in mind then, thanks.
Does rusqlite
integrate well with your structure the way how native_db
does?
native_db
looks like an ORM. The answer may be a simple "no". rusqlite
is a thin interface to sqlite, and its primary interface parses SQL queries.
There are ORMs that use sqlite [1] as a backend, if that is something you are interested in evaluating. sea-orm
and diesel
appear to be the most popular options in that space. [2]
Not necessarily
rusqlite
. ↩︎I do not know much about them. I personally prefer a SQL DSL that enforces syntax correctness at compile time, but not validity against a schema. It's another tradeoff. Keeping my dependencies light makes the system easy to reason about and maintain. And I don't have any runtime overhead that an ORM needs. ↩︎
I see
I don't think they support nested structures (i.e. a field inside a structure that links to another structure) though if I am not mistaken?