Skip to content

Add Postgres.js - #55

Open
porsager wants to merge 4 commits into
geldata:masterfrom
porsager:postgres-js
Open

porsager wants to merge 4 commits into
geldata:masterfrom
porsager:postgres-js

Conversation

@porsager

@porsager porsager commented Jun 8, 2022 •

Copy link
Copy Markdown

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

Comment thread _postgresjs/index.js
r.id as review_id,
r.body as review_body,
r.rating as review_rating,
json_build_object(

Copy link
Copy Markdown
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
Copy Markdown
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.

@porsager porsager Jun 9, 2022 •

Copy link
Copy Markdown
Author

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
Copy Markdown
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
Copy Markdown
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.

This branch has not been deployed

No deployments
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