Bug 1247796

Summary: get_enterable_products() is slow for logged out users
Product: [Community] Bugzilla Reporter: Matt Tyson 🤬 <mtyson>
Component: Bugzilla GeneralAssignee: Jeff Fearn 🐞 <jfearn>
Status: CLOSED NOTABUG QA Contact: tools-bugs <tools-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 4.4CC: jmcdonal, mtahir, mtyson, qgong
Target Milestone: 4.4   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-04 23:33:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Matt Tyson 🤬 2015-07-28 22:46:59 UTC
When fixing bug 1241767 upstream, it was found that get_enterable_products() is extremely slow for logged out users.  We should find out why this is the case and fix it.

Comment 1 Jason McDonald 2015-07-30 00:21:28 UTC
Which pages will this impact?

Comment 2 Matt Tyson 🤬 2015-07-30 00:30:26 UTC
(In reply to Jason McDonald from comment #1)
> Which pages will this impact?

show_bug.cgi and enter_bug.cgi

Comment 3 Jeff Fearn 🐞 2015-08-04 23:24:25 UTC
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 start up a connection.

I've 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

Comment 4 Jeff Fearn 🐞 2015-08-04 23:33:02 UTC
Bug was closed upstream after feedback above was posted there.