Bug 1330756 - scoped search queries use 'ilike' instead of 'like'
Summary: scoped search queries use 'ilike' instead of 'like'
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Performance
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Zach Huntington-Meath
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-26 21:27 UTC by Chris Duryee
Modified: 2017-09-06 07:18 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-09-06 07:18:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 14269 0 None None None 2016-04-26 21:27:29 UTC

Internal Links: 1273256

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!


Note You need to log in before you can comment on or make changes to this bug.