Skip to content

Performance: take target credential names and UUIDs from the iterator - #3080

Open
TheBeast85 wants to merge 1 commit into
greenbone:mainfrom
TheBeast85:perf/get-targets-iterator-columns
Open

Performance: take target credential names and UUIDs from the iterator#3080
TheBeast85 wants to merge 1 commit into
greenbone:mainfrom
TheBeast85:perf/get-targets-iterator-columns

Conversation

@TheBeast85

Copy link
Copy Markdown

What

  • Add the credential UUID columns to TARGET_ITERATOR_COLUMNS and accessors for them and for the credential name columns, which already existed for filtering and sorting but had no accessor.
  • handle_get_targets reads both from the iterator row instead of calling credential_name() and credential_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_targets issued, 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 ips because the accessors address columns by position, and they are deliberately not added to TARGET_ITERATOR_TRASH_COLUMNS, so they are only valid on the non-trash iterator. gmp.c already branches on get.trash.

Measured together with #3067, get_targets with rows=-1 over 1000 targets goes from 1.493 s to 0.370 s.

References

Split out of #3067 as requested.

Checklist

  • Tested manually against a Community Edition stack

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>
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.

1 participant