Skip to content

JS-AK/db-orm-benchmarks

Repository files navigation

db-orm-benchmarks for PostgreSQL 16.x

!NB Prisma connection options for stable work: connection_limit=10 pool_timeout=60

Select data by await Promise.all()

50_000 queries in await Promise.all() ("SELECT email FROM users WHERE users.id = $1") with random users.id

10 separately times

┌───────────────────┬───────────────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬───────────┐
│ orm db            │ avg query per sec |   1     │   2     │   3     │   4     │   5     │   6     │   7     │   8     │   9     │  10     │ avg       │
├───────────────────┼───────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼───────────┤
│ pg.pool           |  9393             |  5889ms |  5241ms |  5259ms |  5259ms |  5277ms |  5269ms |  5299ms |  5218ms |  5233ms |  5289ms |  5323.3ms |
│ drizzle-orm       |  8051             |  6250ms |  6156ms |  6156ms |  6250ms |  6286ms |  6210ms |  6242ms |  6239ms |  6173ms |  6141ms |  6210.3ms |
│ @js-ak/db-manager |  9066             |  5545ms |  5521ms |  5532ms |  5475ms |  5488ms |  5502ms |  5551ms |  5531ms |  5494ms |  5512ms |  5515.1ms |
│ @prisma/client    | 16089             |  3094ms |  3126ms |  3119ms |  3146ms |  3098ms |  3114ms |  3082ms |  3100ms |  3097ms |  3102ms |  3107.8ms |
│ sequelize         |  7855             |  6345ms |  6332ms |  6370ms |  6352ms |  6377ms |  6371ms |  6385ms |  6400ms |  6359ms |  6360ms |  6365.1ms |
│ typeorm           |  7466             |  6674ms |  6680ms |  6736ms |  6649ms |  6705ms |  6633ms |  6633ms |  6665ms |  6639ms |  6952ms |  6696.6ms |
│ mikro-orm         |  6601             |  7597ms |  7541ms |  7621ms |  7551ms |  7529ms |  7594ms |  7454ms |  7597ms |  7689ms |  7574ms |  7574.7ms |
│ objection.js      |  7128             |  7058ms |  7012ms |  7041ms |  6945ms |  7029ms |  6903ms |  7079ms |  6994ms |  7008ms |  7074ms |  7014.3ms |
│ kysely            |  8753             |  5729ms |  5690ms |  5710ms |  5710ms |  5737ms |  5710ms |  5764ms |  5653ms |  5705ms |  5718ms |  5712.6ms |
└───────────────────┴───────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────────┘

Select data by await one by one in for loop

50_000 queries in await one by one in for loop ("SELECT email FROM users WHERE users.id = $1") with random users.id

10 separately times

┌───────────────────┬───────────────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬───────────┐
│ orm db            │ avg query per sec |   1     │   2     │   3     │   4     │   5     │   6     │   7     │   8     │   9     │  10     │ avg       │
├───────────────────┼───────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼───────────┤
│ pg.pool           | 10495             |  4579ms |  4372ms |  4318ms |  4830ms |  4806ms |  4579ms |  4863ms |  4584ms |  5257ms |  5456ms |  4764.4ms |
│ drizzle-orm       |  8318             |  6200ms |  5399ms |  5921ms |  6162ms |  6409ms |  5940ms |  5985ms |  5914ms |  6080ms |  6098ms |  6010.8ms |
│ @js-ak/db-manager |  9907             |  5569ms |  5336ms |  4948ms |  4958ms |  4885ms |  4929ms |  4982ms |  4920ms |  4964ms |  4979ms |  5047.0ms |
│ @prisma/client    |  3132             | 16300ms | 15570ms | 15773ms | 16001ms | 15687ms | 16126ms | 15461ms | 16248ms | 16088ms | 16393ms | 15964.7ms |
│ sequelize         |  6506             |  7533ms |  7344ms |  7304ms |  7594ms |  8112ms |  7889ms |  7708ms |  7722ms |  7728ms |  7920ms |  7685.4ms |
│ typeorm           |  6282             |  7961ms |  7875ms |  7664ms |  7829ms |  7658ms |  8445ms |  8015ms |  8297ms |  7916ms |  7932ms |  7959.2ms |
│ mikro-orm         |  5143             |  9883ms |  9771ms |  9614ms |  9690ms |  9744ms |  9753ms |  9646ms |  9668ms |  9728ms |  9722ms |  9721.9ms |
│ objection.js      |  7633             |  6237ms |  6348ms |  7223ms |  6625ms |  6601ms |  7333ms |  6571ms |  6101ms |  6174ms |  6288ms |  6550.1ms |
│ kysely            | 10021             |  5106ms |  4955ms |  5017ms |  5015ms |  5012ms |  4963ms |  4939ms |  4868ms |  4985ms |  5035ms |  4989.5ms |
└───────────────────┴───────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────────┘

Insert data in one transaction

50_000 users

10 separately times

┌───────────────────┬───────────────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬───────────┐
│ orm db            │ avg query per sec |   1     │   2     │   3     │   4     │   5     │   6     │   7     │   8     │   9     │  10     │ avg       │
├───────────────────┼───────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼───────────┤
│ pg.pool           |  7595             | 10830ms |  6158ms |  6066ms |  6112ms |  6103ms |  6056ms |  6085ms |  6082ms |  6114ms |  6227ms |  6583.3ms |
│ drizzle-orm       |  6014             | 11898ms |  7976ms |  8056ms |  7921ms |  7765ms |  7805ms |  7878ms |  7848ms |  7886ms |  8110ms |  8314.3ms |
│ @js-ak/db-manager |  7010             | 12268ms |  6601ms |  6560ms |  6592ms |  6472ms |  6460ms |  6607ms |  6791ms |  6491ms |  6482ms |  7132.4ms |
│ @prisma/client    |  2467             | 24741ms | 20760ms | 20609ms | 21126ms | 19267ms | 19027ms | 18680ms | 19114ms | 19486ms | 19882ms | 20269.2ms |
│ sequelize         |  4074             | 16436ms | 12077ms | 11783ms | 11745ms | 11857ms | 11790ms | 11697ms | 11886ms | 11777ms | 11674ms | 12272.2ms |
│ typeorm           |  5886             | 12980ms |  8048ms |  7939ms |  7990ms |  8023ms |  7950ms |  8368ms |  7991ms |  7825ms |  7831ms |  8494.5ms |
│ mikro-orm         |  6074             | 12481ms |  7756ms |  7693ms |  7685ms |  7728ms |  7828ms |  8057ms |  7662ms |  7824ms |  7605ms |  8231.9ms |
└───────────────────┴───────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────────┘

Insert data by await Promise.all()

50_000 users

10 separately times

┌───────────────────┬───────────────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬───────────┐
│ orm db            │ avg query per sec |   1     │   2     │   3     │   4     │   5     │   6     │   7     │   8     │   9     │  10     │ avg       │
├───────────────────┼───────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼───────────┤
│ pg.pool           |  8653             |  6540ms |  5679ms |  5852ms |  5646ms |  5675ms |  5644ms |  5624ms |  5667ms |  5691ms |  5763ms |  5778.1ms |
│ drizzle-orm       |  3855             | 17165ms | 12879ms | 12693ms | 12613ms | 13142ms | 12313ms | 12329ms | 12359ms | 12034ms | 12180ms | 12970.7ms |
│ @js-ak/db-manager |  7432             |  8646ms |  6276ms |  6195ms |  6269ms |  7156ms |  6781ms |  6306ms |  6676ms |  6472ms |  6501ms |  6727.8ms |
│ @prisma/client    |  8426             | 11468ms |  5390ms |  5123ms |  5250ms |  5415ms |  5339ms |  5239ms |  5304ms |  5350ms |  5461ms |  5933.9ms |
│ sequelize         |  4553             | 13847ms | 10331ms | 10384ms | 10710ms | 10354ms | 10163ms | 10416ms | 11057ms | 10834ms | 11722ms | 10981.8ms |
│ typeorm           |  4109             | 13368ms | 12551ms | 12332ms | 12191ms | 12117ms | 12570ms | 11282ms | 11358ms | 11122ms | 12800ms | 12169.1ms |
│ mikro-orm         |  3133             | 17911ms | 16755ms | 15215ms | 16769ms | 15971ms | 15537ms | 14951ms | 14988ms | 15033ms | 16474ms | 15960.4ms |
└───────────────────┴───────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────────┘