-
Notifications
You must be signed in to change notification settings - Fork 125
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
Setup SQL server based on pgx frontend/backend protocol #4881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two overall comments:
- It's worth going over the PR and refactoring or clarifying use of the word "Postgres". There are many places where it's not clear that the code pertains to Postgres wire compatibility, as opposed to connecting to an external Postgres database. In some cases, a docstring would help, in other cases, it's worth considering using a term like
psql
orpgwire
instead ofpostgres
. - The code in
runtime/resolvers/postgres_sql.go
is pretty hard to navigate, despite the logic being fundamentally pretty simple. I suggest taking a fresh look at the code with a focus on simplifying and documenting the code. There's also a question (raised in one of the below comments) of whether this should even be a resolver, or if it's better implemented in a dedicated package for Postgres wire compatibility.
Co-authored-by: Benjamin Egelund-Müller <b@egelund-muller.com>
Co-authored-by: Benjamin Egelund-Müller <b@egelund-muller.com>
// NOTE :: the duplicate call to runtime.Resolve is made so that we do not keep the results and eventually leak memory if query is never executed. | ||
// This should resolve fast in most cases since results will be cached. | ||
res, err := s.runtime.Resolve(ctx, &runtime.ResolveOptions{ | ||
InstanceID: instanceID, | ||
Resolver: "metrics_sql", | ||
ResolverProperties: map[string]any{"sql": query}, | ||
Args: map[string]any{"priority": 1}, | ||
UserAttributes: auth.GetClaims(ctx).Attributes(), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only cache for DuckDB, not Druid or ClickHouse. I think running each psql query twice, even if it may lead into DB internal caches is too excessive. If using s.runtime.Resolve
, which returns JSON, why can't that just be passed in here? There is risk of a leaked connection then as far as I can tell?
During continuous analysis of
Also we can simplify our code using |
closes #4817