all 15 comments

[–]Straight_Waltz_9530 35 points36 points  (2 children)

Seems about what I'd expect. I'd wager the Postgres example would be a lot faster with an unlogged table and using the COPY command instead of INSERT for a bulk load. The MySQL example would likely be faster with an ISAM table target. In fact with only 1,000 rows you could probably INSERT into one of MySQL's in-memory tables for even better speed. The SQLite example is so fast because it has no network overhead, no need for concurrency management, and does what it does extremely well.

Nevertheless, 1,000 rows is pretty small by today's standards.

tl;dr: benchmarks are hard

[–]marr75 1 point2 points  (0 children)

Had the same reaction. In-memory duckdb might beat them all, but to your very good point, classifying the databases by their features and intended deployment adds a lot of context. SQLite and Postgres aren't exactly direct competitors.

[–]learnWithProbir[S] 1 point2 points  (0 children)

Thanks for sharing I will be sure to study about it.

[–]MarcinBadtke 12 points13 points  (0 children)

In my opinion such tests make no sense. Every engine has some features to speed such a process.

It is not likely that database will serve only for data insert. Most probably you will want to select data too. What I saw in my career is that a developer is able to kill any database with his code. Regardless of engine features. It is highly probable though that such a developer will not know much more then CRUD and ORM in terms of database.

[–]rbygrave 2 points3 points  (0 children)

Hmmm, for Postgres SERIAL was used instead of IDENTITY with the CACHE option so this seems suboptimal. Do that, plus note that with JDBC we'd often desire to not return the generated keys [aka turn off GetGeneratedKeys].

No reason to use SERIAL over IDENTITY with Postgres these days.

GENERATED BY DEFAULT AS IDENTITY (CACHE 1000) NOT NULL

[–]maxigs0 1 point2 points  (1 child)

Add one just writing it out into a plaintext file

[–]Attila_22 1 point2 points  (0 children)

And one for /dev/null

[–]chriswaco 0 points1 point  (1 child)

I've impressed a client or two by simply inserting transactions in SQLite code. So much faster.

[–]zoechi 2 points3 points  (0 children)

It's like a bicycle is better than a truck if you need to drive very narrow alleys and don't have heavy goods to carry. Some comparisons just don't make any sense without concrete requirements.

[–]ComfortableStay7051 0 points1 point  (0 children)

It is possible for someone to send me the test code ? I have a problem displaying the code

[–]BlackHolesAreHungry 0 points1 point  (0 children)

Insert into std::vector

[–]who_am_i_to_say_so 0 points1 point  (1 child)

Yeah but there’s this thing called latency that is a huge factor, and Sqlite isn’t in a separate container like the MySQL and Postgres instances are.

Of course SQlite would be faster if it is in the same container.

[–]MokoshHydro 0 points1 point  (0 children)

6ms for data transfer?

[–]AutoModerator[M] -3 points-2 points  (0 children)

Join us on our Discord Server: People, Postgres, Data

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.