Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor performance with like operator and escape clause #6593

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Poor performance with like operator and escape clause #6593

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2018-04-27 15:57:13 +0200
From: Manuel <>
To: SQL devs <>
Version: 11.27.11 (Jul2017-SP3)

Last updated: 2018-08-31 13:23:22 +0200

Comment 26412

Date: 2018-04-27 15:57:13 +0200
From: Manuel <>

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Build Identifier:

I have recently is much faster when the escape clause is omitted fromt eh like operator. I can provide you the dataset used in my experiments, but it should not be hard to reproduce the issue on any dataset.

In my use case, submitting a query like:

where "country" like '%Aus%'

is almost ten time faster than

where "country" like '%Aus%' escape '!'

while in this case there is no need to escape anything, hence the escape clause can be removed, I found this behaviour quite strange.

On the opposite, when using ilike, the behaviour seems the reversed, and the query runs faster when escape clause is present.

Reproducible: Always

Steps to Reproduce:

  1. Create containing a varchar column, and a significant amount of records (I tried with 200 million records)
  2. submit a query involving the like operator and the escape clause
  3. submit a query involving the like operator without the escape clause
  4. repeat step 2 and 3 using the ilike operator.

Actual Results:

When using the like operator performance is much better when the escape keyword is omitted. When using the ilike operator performance is much better when the escape keyword is present

Expected Results:

Performance not to be affected by the escape keyword

Comment 26517

Date: 2018-06-27 16:54:06 +0200
From: MonetDB Mercurial Repository <>

Changeset 29ae281a5ed3 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see https//devmonetdborg/hg/MonetDB?cmd=changeset;node=29ae281a5ed3

Changeset description:

If ESCAPE character does not occur in LIKE pattern, treat as if no ESCAPE.
This fixes bug #6593.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant