Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:28:35+00:00 2026-06-13T04:28:35+00:00

I have got three tables that are supposed to be joined, the query looks

  • 0

I have got three tables that are supposed to be joined, the query looks like this:

select distinct a.job 
from a
join  b on  a.job=b.id 
join  c on  c.id =a.path  
where c.path like '//depot/a/b/c/d/MARSR_CL286896_297899/%';

This query will always timeout. However, if I change the path comparison to some condition else, the query just run perfectly, for example:

 select distinct a.job 
 from a
 join  b on  a.job=b.id 
 join  c on  c.id =a.path  
 where c.path like '//depot/a/b/c/d/%';

Considering the difference of the path parameter, will the numbers and underscores the culprit that slows the statement? I have created index for the ‘path’ field

result of ‘explain’ command

1   SIMPLE  b   index   PRIMARY       job      62           73580   Using index; Using temporary
1   SIMPLE  a   ref     path,job      job       8   b.id    153 
1   SIMPLE  c   eq_ref  PRIMARY,path  PRIMARY   8   a.path  1   Using where
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:28:37+00:00Added an answer on June 13, 2026 at 4:28 am

    Yes. An underscore is a wildcard character too, which matches any (single) character, so this makes the query quite a lot more complex, since it can only use the index on the first part, until the first underscore, and needs to scan all matches on that part with a relatively complex regular expression to match the rest, while otherwise it could do a simple ‘starts with’.

    You should escape it to treat it as a normal underscore. You can escape it by adding a \ in front of the underscores. You can also escape a percent sign like this, using \% if you would need to.

    select distinct a.job 
    from a
    join  b on  a.job=b.id 
    join  c on  c.id =a.path  
    where c.path like '//depot/a/b/c/d/MARSR\_CL286896\_297899/%';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got three tables in a MySql database that I'm joining in a query
I have to copy data for one student (clone student) that encompass three tables:
I've got three DataTables that I need to join together, and use the joined
In Unix, I have got three main files. One of them is a library
I'm using Google Test Framework to set some unit tests. I have got three
I have got as follows: use constant ABC => ('one', 'two', 'three'); and I
I've got an app with three spinners, they have unique IDs and I'm trying
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have three tables (these are the relevant columns): Table1 bookingid, person, role Table2
I've got this php page where I do a search which returns data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.