-
Notifications
You must be signed in to change notification settings - Fork 274
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
Remove FLUSH from CF integration #736
Conversation
Interesting. During my initial testing there was a noticeable perf difference directly against PostgreSQL. Even so, the cloudflare code you edited is generated from |
90ad051
to
bd72c09
Compare
Ah alright, thanks for letting me know! Would you mind letting me know what the perf testing looked like? I'd love to reproduce it on my end to see the results if possible. I'll look into integrating this into the main src directory as well then |
Yeah, check out https://github.com/porsager/postgres-benchmarks |
bd72c09
to
cbc4f36
Compare
@porsager Should be updated for all tests and in the main source directory. The changes made essentially check if existing known type mappings exist and cut the round trip used by the |
@porsager Benchmarks look like the fluctuate between this implementation and the existing implementation, so I don't see a visible constant difference on my end. EDIT: Removed the log I missed, seems like benchmarks stay close to the same locally. Anything else needed to merge this in? |
Interesting. Can you check if your PR makes sense on: #392 ? |
@porsager If I understand #392 correctly, it allows explicit definitions of types or inference from postgres, so in the case where all types in a query are explicitly defined, this would provide a fast path of sorts and not have to wait for the |
No, it's actually the opposite 🙂 It removes any js type inference to only rely on what is provided by PostgreSQL in ParameterDescription. I guess the PR description needs a touchup 😬 |
Ah makes sense. What was the conversation about the user explicitly specifying a type? would that be mapped prior to receiving the |
No, that was about explicitly specifying the type through sql, so eg |
In that case then, where no inference is needed, would there still be a need to receive information from the |
Hmm.. maybe I'm misunderstanding something. The way I see it we would always need to wait for ParameterDescription because it is Postgres that tells us the type so we can properly serialize the values before passing them to Postgres. That's why I was thinking it conflicted with this PR because there would never be any js inference of types. |
cbc4f36
to
4eaa0a9
Compare
@porsager Ah my bad, I misunderstood then. I'd still be in favor of merging this PR for now as it seems like the JS inference will take a while to deprecate completely (a new major version release it seems), and if any other inference is thought out in the future this would still apply if or when that is implemented if that makes sense |
@porsager is this something you'd still want to merge + tag a release on? We'd love to get Postgres.js working w/ Hyperdrive + Workers again! |
Definitely! I've just been too busy to look at it, but today and tomorrow I'll be diving into these things again! |
Would also like to use Hyperdrive caching, any idea where the commit that closed this issue ended up? When clicking through it says "This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository." |
Hi John. The PR didn't solve the issue, it's a bit deeper than that, and requires ignoring the describe part of the protocol which will change the behavior of Postgres.js. I'm talking with CloudFlare to see if we can find a good solution. |
@porsager thanks for clarifying 🙏 |
The intermediate use of
FLUSH
in the current implementation for Cloudflare workers causes incompatibilities with Hyperdrive's caching service.In order to support caching, this PR aims to remove the intermediate use of
FLUSH
when executing extended Postgres queries favoring sending the query all-together. This allows Hyperdrive's caching service to cache the full queries sent and serve results from cache for extended queries, resulting in less round-trips overall.I believe all existing tests should pass (I ported the connection.js changes onto the deno implementation and ran the tests there). I also ran local tests to ensure compatibility.