Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1330756

Summary: scoped search queries use 'ilike' instead of 'like'
Product: Red Hat Satellite Reporter: Chris Duryee <cduryee>
Component: PerformanceAssignee: Zach Huntington-Meath <zhunting>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: bbuckingham, bkearney, cduryee, sshtein
Target Milestone: UnspecifiedKeywords: Performance, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-06 07:18:18 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 Chris Duryee 2016-04-26 21:27:29 UTC
Description of problem:

Postgresql allows for 'ilike' which is case-insensitive like. However, 'ilike' cannot use indexes, resulting in slow queries.

There are a couple of ways to go about fixing this but one way would be to call lower() on both sides of the comparisons, which would let us use LIKE. There is some discussion in http://grokbase.com/t/postgresql/pgsql-hackers/12cwwmjgs9/ilike-vs-indices about the pros and cons of this (mostly related to locale concerns), but I think for the types of data Katello works with, I think a "lowercase everything when searching" approach is OK.

NOTE: this bz is for a SQL optimization to make searches faster, for example when searching for an erratum. Ideally, it should have no functionality impact.

Version-Release number of selected component (if applicable): 6.2.0 beta

Comment 1 Bryan Kearney 2016-04-27 19:21:37 UTC
Upstream bug assigned to zhunting

Comment 3 Shimon Shtein 2017-09-05 08:27:03 UTC
The ILIKE operator comes from scoped search (https://github.com/wvanbergen/scoped_search/blob/c874ab5de817a6d619baaa1d07129b5743a98708/lib/scoped_search/query_builder.rb#L536), so I doubt we want to customize this part easily. 
If there is a place where LIKE queries are very common, we can explore the option of text indices: https://blog.2ndquadrant.com/text-search-strategies-in-postgresql/.

Before we go there, IMHO we should prove negative impact on the user, since it adds more complexity to DB structure.

Comment 4 Chris Duryee 2017-09-05 13:44:22 UTC
Ya agreed, I think its OK to close this bug out. It was found when investigating another issue, but https://bugzilla.redhat.com/show_bug.cgi?id=1330306 already reduced the time by 1/2 without making any changes to scoped search.

Comment 5 Shimon Shtein 2017-09-06 07:18:18 UTC
Closing for now, as it seems like a premature optimization from the last comment.

Thanks, Chris!