Closed Bug 1188451 Opened 9 years ago Closed 9 years ago

get_enterable_products() is slow for logged out users

Categories

(Bugzilla :: Bugzilla-General, defect)

defect
Not set
minor

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: LpSolit, Unassigned)

References

Details

As mentioned in bug 1183492 comment 9, the first query of get_enterable_products() is extremely slow for logged out users compared to logged in users. Around 70 times slower. We should understand why and fix that.
I've been testing this and I don't think it's a bug. The extra cost appears to be connecting to the DB. The way this test is constructed a logged in user will already have a connection as they have accessed the profiles table, whereas a logged out user hasn't done that so needs to connect.

I've added timing around Bugzilla->dbh in sub get_enterable_products and running the tests as per https://bugzilla.mozilla.org/show_bug.cgi?id=1183492#c9

$ perl -Mlib=lib -MTime::HiRes -MBugzilla -MBugzilla::User -wE 'my $user = Bugzilla::User->new(1); $user->groups_as_string; my $t0 = Time::HiRes::time(); my $groups = $user->get_enterable_products; my $t1 = Time::HiRes::time(); say $t1 - $t0'
2.86102294921875e-06
0.0195839405059814

$ perl -Mlib=lib -MTime::HiRes -MBugzilla -MBugzilla::User -wE 'my $user = Bugzilla::User->new(0); $user->groups_as_string; my $t0 = Time::HiRes::time(); my $groups = $user->get_enterable_products; my $t1 = Time::HiRes::time(); say $t1 - $t0'
0.0166680812835693
0.0258760452270508
Hum right, good catch. :)
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.