Skip to content

Bug 2053504 - Need to add index to tracking_flags_values table for better performance from search - #2665

Open
dklawren wants to merge 2 commits into
mozilla-bteam:masterfrom
dklawren:2053504
Open

Bug 2053504 - Need to add index to tracking_flags_values table for better performance from search#2665
dklawren wants to merge 2 commits into
mozilla-bteam:masterfrom
dklawren:2053504

Conversation

@dklawren

@dklawren dklawren commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new database index to improve query performance when looking up tracking flag values (notably impacting /bzapi/bug and REST search paths that touch tracking_flags_values).

Changes:

  • Add a non-unique index on tracking_flags_values.tracking_flag_id.
  • Update the TrackingFlags extension’s abstract schema to declare the new index.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread extensions/TrackingFlags/Extension.pm
Comment thread extensions/TrackingFlags/Extension.pm
@dklawren dklawren changed the title Bug 2053504 - Need to add index to tracking_flags_values table for better performance from /bzapi/bug and REST search Bug 2053504 - Need to add index to tracking_flags_values table for better performance from REST search Aug 6, 2026
@dklawren dklawren changed the title Bug 2053504 - Need to add index to tracking_flags_values table for better performance from REST search Bug 2053504 - Need to add index to tracking_flags_values table for better performance from search Aug 6, 2026
@dklawren
dklawren requested review from cgsheeh and removed request for zzzeid August 6, 2026 21:54
INDEXES => [
tracking_flags_values_idx =>
{FIELDS => ['tracking_flag_id', 'value'], TYPE => 'UNIQUE',},
tracking_flags_values_tracking_flag_id_idx => ['tracking_flag_id'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the plan from the bug, the filter passes all 7,014 rows it scans, and Query Insights has it averaging 3,499 rows returned out of a ~7,000 row table. At that selectivity MySQL will keep picking the table scan over a range scan, so I don't think this index will change the plan. Have you been able to try it on a copy of prod?


$dbh->bz_add_index('tracking_flags_values',
'tracking_flags_values_tracking_flag_id_idx',
[qw(tracking_flag_id)]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other thing that stands out in the screenshot from the bug is 2.4M calls at 9ms - preload_all_the_things re-runs this on every Flag->match, and get_all only caches in request_cache. Since the values change rarely, would caching them with memcached get us more than an index will?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants