Do not refer to search options by ID literals #16607
Merged
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.
The search engine makes some assumptions about search option IDs that is correct in most cases, but not all (like Followups). Rather than mess with changing search option IDs, the better solution is to replace all cases where we use hard-coded search option IDs to refer to a specific option.
For example, it assumes that ID 1 is always present and always the name field. In followups, this is the content field. Having the content field shown by default is very resource intensive. Worse, the default sort is always ID 1 which means the search query suddenly becomes much less performant as it has to scan the entire table. When creating criteria filters for followups in the webhook feature on a database with 1.5 million followups, it was taking approximately 18 seconds to load the tab. With these changes, I expect it to be a few ms only.