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

Change: Check trash target references before accessing them #2193

Merged
merged 1 commit into from
May 22, 2024

Conversation

mattmundell
Copy link
Contributor

What

In the trash case of GET_TARGETS check that dependent resources exist before trying to access info about them.

Specifically, in handle_get_targets check ssh_credential, smb_credential, etc before passing them to functions like trash_credential_name.

Why

This saves the SQL statements of trash_credential_name etc when ssh_credential etc are 0. These statements would have always returned NULL.

Note that this only affects the trash case, because the regular case was already doing the check.

The speedup looks mild if any, but we might as well skip the extra SQL. With 1600 trash targets:

time o m m '<get_targets filter="rows=-1 sort=name" trash="1"/>' > /tmp/targ
before: 9s,8s,7s
after: 7s,6s,6s

@mattmundell mattmundell requested a review from a team as a code owner May 7, 2024 14:23
Copy link

github-actions bot commented May 7, 2024

Conventional Commits Report

Type Number
Changed 1

🚀 Conventional commits found.

@a-h-abdelsalam a-h-abdelsalam merged commit 1a336ad into main May 22, 2024
9 checks passed
@a-h-abdelsalam a-h-abdelsalam deleted the check-target-refs branch May 22, 2024 11:37
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.

2 participants