News for hackers. Stuff that matters.
Re:15k inserts/s with Rust and SQLite (2021) by VWWHFSfQ on Sunday April 02, 2023 @04:56PM (#35415124)
15k inserts/second is basically nothing. This is just a batch load of INSERT statements.

Now do it while simultaneously serving 15k selects/second.

Now try it with 15k counts/second. You'll see where this breaks down fast.

Re:15k inserts/s with Rust and SQLite (2021) by ijidak on Sunday April 02, 2023 @05:08PM (#35415223)
Can you qualify your statement that this is nothing?

How many CPUs and cores are available? Are we talking SSDs?

How much data is being inserted?

What are the keys and index?

15,000 per second seems like plenty much in some contexts.

Re:15k inserts/s with Rust and SQLite (2021) by VWWHFSfQ on Sunday April 02, 2023 @05:24PM (#35415383)
The schema:

    CREATE TABLE IF NOT EXISTS users (
        id BLOB PRIMARY KEY NOT NULL,
        created_at TEXT NOT NULL,
        username TEXT NOT NULL
    );

The data:

    let user = User {
        id: uuid::Uuid::new_v4(),
        created_at: chrono::Utc::now(),
        username: String::from("Hello"),
    };

If you can't insert 15,000 of these records per second then there's something wrong with your database. I'm aware that people are all on the SQLite hype train, but this kind of stuff is table-stakes.

I really like SQLite. But this blog isn't any kind of great performance indicator for it.

Re:15k inserts/s with Rust and SQLite (2021) by snacktaster on Sunday April 02, 2023 @05:37PM (#35415517)
This entire post reduces to:

    insert into users (id, created_at, username) values ("<id>", "<created_at>", "Hello"), ...15,000 times.

And we're going to be impressed with sqlite's performance?
Re:15k inserts/s with Rust and SQLite (2021) by Aeolun on Sunday April 02, 2023 @08:37PM (#35417064)
Well, some people think 3 inserts per second is fast, so maybe it gives some perspective? To be fair, I wouldn’t expect those to hang around hackernews though.
Re:15k inserts/s with Rust and SQLite (2021) by ZephyrBlu on Sunday April 02, 2023 @06:20PM (#35415890)
I think a lot of people have forgotten or don't know how powerful CPUs are. Simple operations should be insanely fast, like easily sub-millisecond if not sub-nanosecond fast.
Re:15k inserts/s with Rust and SQLite (2021) by Aeolun on Sunday April 02, 2023 @08:36PM (#35417054)
You can double the performance of this whole thing by inserting 2 values at a time.
Re:15k inserts/s with Rust and SQLite (2021) by eyegor on Sunday April 02, 2023 @09:56PM (#35417620)
I don't see why you wouldn't just bundle them all into a transaction at that point. The idea of 1 insert at a time is to roughly estimate the overhead/perf in a real environment, where you're only adding 1 entry at a time.
Re:15k inserts/s with Rust and SQLite (2021) by ijidak on Sunday April 02, 2023 @09:11PM (#35417321)
But, for insert, the CPU is not the bottleneck. It's I/O constrained.

Disk I/O has always been the bottleneck for writes.

Re:15k inserts/s with Rust and SQLite (2021) by jandrewrogers on Sunday April 02, 2023 @09:37PM (#35417515)
Counterintuitively, write performance in modern databases is primarily constrained by disk read performance.

That said, it is increasingly rare for disk I/O to be a bottleneck for inserts. When your storage will happily sustain 10+ GB/s of write throughput, you tend to run out of things like network and memory bandwidth first.

Re:15k inserts/s with Rust and SQLite (2021) by zhte415 on Monday April 03, 2023 @12:53AM (#35418692)
I think it's useful stress testing for when your product goes viral.

For example, if the whole world wanted to create an account, and an account consisted of a UUID and a date, it'd take 5.4 days using this metric as a minimum viable benchmark.

While this is a tongue in cheek comment, it has a valid foundation: 15,000 seems like a large number, and 1 second seems like a small amount of time. On the other hand, 5.4 days seems like quite a large number. Likewise at small scales, 15,000/second operated at a fidelity only able to capture 0.0005% of a typical processor's clock.

It's all about context.

This is not to say that the ability to casually write 15,000 things a second to a database is not impressive in itself.

Re:15k inserts/s with Rust and SQLite (2021) by andrewstuart on Sunday April 02, 2023 @05:20PM (#35415353)
15K doesn't seem particularly noteworthy.

I made a prototype message queue in Rust that processed about 7 million messages/second. That was running from RAM.

I also had a prototype that ran from disk and it very rapidly maxed out the random write performance of the SSD. Can't remember the number but it was in the order of 15K to 30K messages a second, bottlenecked by the SSD.

If the sqlite test is writing to disk it is likely also bottlenecked at the disk.

Re:15k inserts/s with Rust and SQLite (2021) by gomezjdaniel on Sunday April 02, 2023 @05:42PM (#35415557)
> I made a prototype message queue in Rust that processed about 7 million messages/second. That was running from RAM.

Can you share the source code?

Re:15k inserts/s with Rust and SQLite (2021) by andrewstuart on Sunday April 02, 2023 @06:52PM (#35416138)
It was pure garbage - a failed attempt to learn Rust.
Re:15k inserts/s with Rust and SQLite (2021) by re-thc on Sunday April 02, 2023 @08:34PM (#35417041)
Need some garbage collection added?
Re:15k inserts/s with Rust and SQLite (2021) by marginalia_nu on Sunday April 02, 2023 @05:54PM (#35415669)
To be fair it's very easy to outperform a DBMS by not offering ACID guarantees.
Re:15k inserts/s with Rust and SQLite (2021) by osigurdson on Sunday April 02, 2023 @09:13PM (#35417334)
Agree. I know for Postgres, we are getting at least 50K / second sustained and not doing anything special - other than using bulk insert.
Re:15k inserts/s with Rust and SQLite (2021) by phiresky on Sunday April 02, 2023 @06:49PM (#35416119)
If WAL mode is enabled and the inserts are running in a separate thread or process then the performance will be exactly while any amount of selects are running.
Re:15k inserts/s with Rust and SQLite (2021) by pkolaczk on Monday April 03, 2023 @09:36AM (#35423329)
For reference, a single Apache Cassandra node does about 150k inserts/second or also 150k selects/second on my laptop. All that from a single client thread using a very similar approach (also in Rust with async).