Performance: take target credential names and UUIDs from the iterator - #3080
Open
TheBeast85 wants to merge 1 commit into
Open
Performance: take target credential names and UUIDs from the iterator#3080TheBeast85 wants to merge 1 commit into
TheBeast85 wants to merge 1 commit into
Conversation
handle_get_targets looked up the name and the UUID of every credential of every target with credential_name() and credential_uuid(), one statement each. Over 1000 targets and six login types that is a large part of the 12196 statements get_targets issued, while only 156 ms of 1498 ms were spent actually executing SQL. The name columns already existed in TARGET_ITERATOR_COLUMNS for filtering and sorting but had no accessor. Add the UUID columns next to them and read both from the iterator row. The new columns are appended after "ips" because the accessors address columns by position, and they are not added to TARGET_ITERATOR_TRASH_COLUMNS, so the accessors are only valid on the non-trash iterator; gmp.c already branches on get.trash. Measured together with the prepared statement cache, get_targets with rows=-1 over 1000 targets goes from 1.493 s to 0.370 s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
TARGET_ITERATOR_COLUMNSand accessors for them and for the credential name columns, which already existed for filtering and sorting but had no accessor.handle_get_targetsreads both from the iterator row instead of callingcredential_name()andcredential_uuid()per target and per login type.Why
Each of those calls was one statement. Over 1000 targets and six login types that is a large part of the 12196 statements
get_targetsissued, while only 156 ms of 1498 ms were spent actually executing SQL — the statement count is what costs, not the individual statement.The new columns are appended after
ipsbecause the accessors address columns by position, and they are deliberately not added toTARGET_ITERATOR_TRASH_COLUMNS, so they are only valid on the non-trash iterator.gmp.calready branches onget.trash.Measured together with #3067,
get_targetswithrows=-1over 1000 targets goes from 1.493 s to 0.370 s.References
Split out of #3067 as requested.
Checklist