Closed Bug 825805 Opened 12 years ago Closed 11 years ago

add an index to fielddefs on (custom,type,sortkey);

Categories

(Bugzilla :: Database, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: glob, Assigned: dkl)

References

Details

Attachments

(1 file, 2 obsolete files)

in bug 824998 sheeri has determined that the fielddefs table would benefit from an index on (custom,type,sortkey).
Assignee: database → dkl
Status: NEW → ASSIGNED
Attachment #697934 - Flags: review?(glob)
Comment on attachment 697934 [details] [diff] [review]
Patch to update unique index on fielddefs table (v1)

>+            fielddefs_name_idx => {FIELDS => [qw(name type sortkey)],

We want (*custom* type sortkey), not name.
Attachment #697934 - Flags: review?(glob) → review-
(In reply to Frédéric Buclin from comment #2)
> Comment on attachment 697934 [details] [diff] [review]
> Patch to update unique index on fielddefs table (v1)
> 
> >+            fielddefs_name_idx => {FIELDS => [qw(name type sortkey)],
> 
> We want (*custom* type sortkey), not name.

Ugh. Yeah completely missed that. New patch coming.
Attachment #697934 - Attachment is obsolete: true
Attachment #698015 - Flags: review?(LpSolit)
Comment on attachment 698015 [details] [diff] [review]
Patch to add unique index to fielddefs table (v2)

>+            fielddefs_custom_idx  => {FIELDS => [qw(custom type sortkey)],
>+                                      TYPE => 'UNIQUE'},

Not UNIQUE! You can have two custom fields of the same type (e.g. Free Text) with the same sortkey. I'm surprised checksetup.pl didn't crash in your testing. :)
Attachment #698015 - Flags: review?(LpSolit) → review-
Attachment #698015 - Attachment is obsolete: true
Attachment #698098 - Flags: review?(LpSolit)
I scanned our codebase, and I cannot find any place where queries of the form

 WHERE custom = 1 AND type = X

as described in bug 824998 are triggered. I added debug code into Bugzilla::Object::_do_list_select() to intercept queries generated by it, but none of these queries are of the form above. There are tons of queries of the form:

 WHERE visibility_field_id = X

and

 WHERE value_field_id = X

though. Those are generated by [% legal_value.controlled_values %] and [% field.controls_visibility_of %] in bug/field-events.js.tmpl.

I don't want to add a new index if we cannot determine which code will benefit from it.
(In reply to Frédéric Buclin from comment #7)
> I scanned our codebase, and I cannot find any place where queries of the form
> 
>  WHERE custom = 1 AND type = X
> 
> as described in bug 824998 are triggered.


Ah, I found it! This comes from Bugzilla::Bug::AUTOLOAD in Bugzilla 4.0:

      $self->{_multi_selects} ||= [Bugzilla->get_fields(
          {custom => 1, type => FIELD_TYPE_MULTI_SELECT })];

But AUTOLOAD is gone since Bugzilla 4.2, see bug 600123. That was the single place doing such queries. So there is no benefit in adding this new index in Bugzilla 4.2 and newer. Suggesting WONTFIX.
Comment on attachment 698098 [details] [diff] [review]
Patch to add new index to fielddefs table (v3)

This index is now irrelevant in Bugzilla 4.2 and newer, see my previous comment.
Attachment #698098 - Flags: review?(LpSolit)
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
great detective work....glad it's fixed in the new version!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: