Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to Postgres.js? #309

Open
sjvans opened this issue Oct 18, 2023 · 5 comments
Open

switch to Postgres.js? #309

sjvans opened this issue Oct 18, 2023 · 5 comments

Comments

@sjvans
Copy link
Contributor

sjvans commented Oct 18, 2023

Postgres.js claims to be the fastest postgres client. See benchmarks.

Should we switch?

@gregorwolf
Copy link
Collaborator

I think we should wait a bit until the user base of Postgres.js grows:

Screenshot 2023-10-18 at 13 32 12

Screenshot 2023-10-18 at 13 33 14

@gregorwolf
Copy link
Collaborator

Is the public domain license an issue?

@vobu
Copy link
Collaborator

vobu commented Feb 27, 2024

oooooh, I think we might even want to look at https://github.com/electric-sql/pglite 👀 (once parametrised queries are supported)

@sjvans
Copy link
Contributor Author

sjvans commented Mar 6, 2024

oooooh, I think we might even want to look at https://github.com/electric-sql/pglite 👀 (once parametrised queries are supported)

I think these are parallel activities though, as you wouldn’t necessarily use pglite in production

@BobdenOs
Copy link
Contributor

BobdenOs commented Mar 6, 2024

While it is possible to provide support for multiple drivers. It comes with quite some maintenance overhead. Especially for Postgres as it does not support some required scenarios on its network protocol. For @cap-js/hana it provides support for both hana-client and hdb. So the same model could be added into the Postgres Service.

The main feature to consider is streaming. As for the current implementation there is bi-direction streaming (in, out). These two implementations both hijack the underlying tcp connection and cannot be beaten by any other implementation. Unless they implement a more efficient tcp implementation then nodejs currently provides.

Especially when looking at the performance the current implementation can reach vs using the driver alone.

const dataset = new Array(1 << 8).fill('').map((_, i) => [i, i + ''])
// 256rows (231.8066999912262ms)
await cds.tx(async tx => {
  await tx.run(`INSERT INTO ${Books.name.replace(/\./g, '_')} (ID, title) values ($1,$2)`, dataset)
})

const entries = dataset.map(r => ({ ID: r[0], title: r[1] }))
// 256rows (24.753600001335144ms) 
await INSERT(entries).into(Books)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants