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

Use fixed number of query args in StorageReadObjects #1044

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

redbaron
Copy link
Contributor

When selecting variable number of objects it's better to keep number of SQL query arguments constant, otherwise query statistics explode, because from PostgreSQL perspective query with different number of arguments is a distinct query.

server/db.go Show resolved Hide resolved
} else {
whereClause += fmt.Sprintf(" (collection = $%v AND key = $%v AND user_id = $%v AND (read = 2 OR (read = 1 AND user_id = $%v))) ", l+1, l+2, l+3, l+4)
params = append(params, id.Collection, id.Key, id.UserId, caller)
reqUid = uuid.Nil
Copy link
Member

Choose a reason for hiding this comment

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

Should not be needed, the empty value for a uuid.UUID is uuid.Nil already.

server/db.go Outdated
var pgErr *pgconn.PgError
if errors.As(err, &pgErr) && pgErr.Code == pgerrcode.SerializationFailure {
// A recognised error type that can be retried.
goto retry
Copy link
Member

Choose a reason for hiding this comment

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

Not a fan of the goto. Can we rewrite this more neatly, and also implement the max retries we've done elsewhere already?

When selecting variable number of objects it's better to keep number of
SQL query arguments constant, otherwise query statistics explode, because
from PostgreSQL perspective query with different number of arguments is
a distinct query.
@zyro zyro merged commit 06ed00f into master Jul 18, 2023
2 checks passed
@zyro zyro deleted the storage-read-multi-args branch July 18, 2023 19:44
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.

None yet

2 participants