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

Add Postgres.js #55

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add Postgres.js #55

wants to merge 4 commits into from

Conversation

porsager
Copy link

@porsager porsager commented Jun 8, 2022

Hi. Here's an initial shot at adding Postgres.js to the sql benchmarks. I've only implemented the 3 cases tested in the run for now.

By the way - awesome job on EdgeDB, I'm looking forward to have time to give it a closer look! I think it would be really cool to have a Postgres.js style surface api for the EdgeDB javascript (node/deno) driver

fixes #44

r.id as review_id,
r.body as review_body,
r.rating as review_rating,
json_build_object(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other implementations aren't using in-database JSON encoding, so this wouldn't be a fair comparison of binding performance. See also #48 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is postgres.js capable of decoding arrays and tuples? If so, I'd use the asyncpg queries for fairness.

Copy link
Author

@porsager porsager Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elprans it does arrays but not record tuples. I did do a query assembling things in the client just like the go example, but it didn't do any performance difference (i actually think it was a bit faster). In my opinion I think using json in the query is more fair, since PostgreSQL can do so much more - so if you want to honestly compare eg EdgeDB queries to PostgreSQL - choose the best from both worlds. I can change it to match the go query or asyncpg, but I think it would make more sense to maybe change them to use this query instead? I might be biased since I want to stay as close to the "native" queries as possible, which I guess is also part of your reasons for making EdgeDB?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that JSON strips rich type information, e.g. instead of a proper Date object for a timestamp column, you get a string, etc, which is significantly less useful for application code. This isn't entirely obvious here, because the current benchmark code just serializes things back to JSON, but it's an important aspect nonetheless.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a variation of each query that returns JSON directly, if supported. In fact, EdgeDB explicitly supports database-side JSON encoding of results of arbitrary queries.

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

Successfully merging this pull request may close these issues.

Add Postgres.js
2 participants