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.
At work my team uses Notary and we encountered a serious inefficiency when it comes to database queries from the
tuf_files
table. The table lacks an index on thegun
field, which makes the MySQL/MariaDB engine perform a full table scan each timegun
is used in aWHERE
clause (which most Notary server endpoints use). We have lots of repositories indexed intuf_files
, which started to become a problem and we noticed this issue.A default BTree index on
gun
makes sense since GUNs are tree-like in nature (they are even represented like directory structures on disk). Making this change in our environment sped up the Notary server significantly.Note: Just to avoid confusion, it is important to mention that there is an index on
tuf_files
calledgun
, but it is a composite UNIQUE KEY index consisting ofgun
,role
andversion
. This index doesn't help when there is aWHERE
clause involving thegun
column alone, so the DB engine performs a full table scan anyway.