←
Drizzle ORM11,670 posts
Drizzle ORM avatar

Drizzle ORM

@DrizzleORM

Sequel Statement Builder

◷ Joined September 2022▧ 1,711 Photos and videos
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Oct 21

Since 4 is compromised we're shipping drizzle rc5 ▪︎ FINALLY incremental snapshots -93% size and LoC ▪︎ Effect v4 types ▪︎ ORDER BY for relations in queries ▪︎ perf boost for complex relational queries ▪︎ [PREVIEW] drizzle postgres driver ▪︎ fixes and improvements

Post attachment
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 17

We will remove cache from drizzle Wrong wording

We will be dropping Drizzle Cache API in v1 Caching query responses in ORM is: ▪︎ wrong place ▪︎ easiest footgun ▪︎ nightmare for us, library maintainers let me know if you use drizzle cache API, we will propose you a proper way

Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 16

We will be dropping Drizzle Cache API in v1 Caching query responses in ORM is: ▪︎ wrong place ▪︎ easiest footgun ▪︎ nightmare for us, library maintainers let me know if you use drizzle cache API, we will propose you a proper way

Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 16

and it's going to be BLAZINGLY FAST A table with 20 columns, 4 of which have defaults. Every row sets the other 16 and leaves those 4 to the database.

Post attachmentPost attachment
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 16

How to make Postgres inserts not suck? 2 things: ▪︎ binary representation of a DEFAULT 🙃 ▪︎ insert statement prepared without its rows 🙃 every cell value has header on insert ▪︎ >=0 means that many bytes follow ▪︎ -1 is NULL ▪︎ -2 vacant, lets make DEFAULT voila:

Post attachment
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 16

How we make it suck less now? We built a postgres driver from scratch, we open a transaction an pipeline statements with N number of params autotune based on columns count, we autoname statemts if we see them more than once, which allows db to not reparse them. And we make sure we neither waste local memory, nor on db! All so you can just:

Post attachmentPost attachment
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 16

Inserting with VALUES has every feature, but the rows are in the statement text. You can't pass an arbitrary number of rows. Every cell is a parameter, and a statement holds at most 65,535 of them. With 20 columns that is 3,276 rows. So the client cannot hand the server "these rows": it has to cut them into statements in a loop so that none goes out of bounds, wrap the loop in a transaction so the batch still succeeds or fails as a whole, and stitch the results of the statements back together. That is bulk insert implemented on the client, on top of a statement that was never bulk

Post attachment
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 16

Neither of the above is a silver bullet Neither of the above is a no bullet at all, tbh

Post attachment
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 16

Postgres inserts suck Good news are: ▪︎ we made them suck less ▪︎ we know how to make them not suck So, why they suck. This is how you insert multiple values in postgres...

Post attachment
Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 14

there's so much bells and whistles for us to optimise around prepared named statements with databases to eliminate reparse overhead on the database server side which we can completely eliminate by sending already parsed statements in binary?

Drizzle ORM avatar
Drizzle ORM@DrizzleORM·Nov 12

ok, even without named statements we managed to make kysely ~20% faster, measuring now with named statements, shall be significantly faster

Post attachment