Add index on targets_login_data - #3071
Open
TheBeast85 wants to merge 1 commit into
Open
Conversation
The target iterator selects the credential and the login port for six login types, each with its own correlated subquery on targets_login_data. Without an index the table is scanned once per target and subquery, so listing targets gets slower with the square of the number of targets that have credentials. On an installation with 4500 targets, each with an ssh credential, listing all targets took 5.1 s. With the index it takes 1.7 s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
greenbonebot
enabled auto-merge (rebase)
July 30, 2026 10:08
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
Add an index on
targets_login_data (target, type)Why
The target iterator looks up the credential of every login type with its own subquery, so listing targets scans this table once per target and login type. The table only had its primary key on
id.create_indexis idempotent and runs fromcreate_tables, so existing databases pick the index up on the next start without a migration.