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 3244662
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:34:41+00:00 2026-05-17T18:34:41+00:00

I have a strange problem with my query trying to join 3 tables. The

  • 0

I have a strange problem with my query trying to join 3 tables. The tables descibed:

2 similar tables like this (entr_es):

Field   Type    Null    Key Default Extra  
espid   int(11) NO  PRI NULL    auto_increment 
haslo   text    NO  MUL NULL   
kat int(11) NO  NULL   

The second table looks the same, except the first column whis is named polid.

The third table is:

Field   Type    Null    Key Default Extra
polid   int(11) NO  PRI NULL
espid   int(11) NO  PRI NULL

And here are the queries:

The first one:

SELECT entr_pl.haslo AS srchaslo, entr_es.haslo AS trghaslo
FROM entr_es, entr_pl, rel_pl_es
WHERE entr_pl.polid=rel_pl_es.polid
AND rel_pl_es.espid=entr_es.espid
AND entr_pl.haslo LIKE "%ludzk%"

works fast, about 0.2 sec. which is enough for me.

But the other one, which is nearly the same, but inverse:

SELECT entr_es.haslo AS srchaslo, entr_pl.haslo AS trghaslo
FROM entr_es, entr_pl, rel_pl_es
WHERE entr_pl.polid=rel_pl_es.polid
AND rel_pl_es.espid=entr_es.espid
AND entr_es.haslo LIKE "%hum%"

works bad – the results are OK, but the query takes about 2.2 to execute and I dont know why. I looked at the EXPLAIN, but the only thing I found is that the second query, the slow one, is “using temporary”. I don’t know why. I’m sure there is something obvious that I can’t see, maybe there is also a way to simplify these queries.

Please help and great thanks in advance,
Best regards,

Kamil

=======

I’m terribly sorry – I went throught it once again and the slowdown problem is elsewhere.

It’s the

ORDER BY srchaslo

clause on the end of each query. I ommited it in my first post thinking it’s not relevant, but it is. It works fine and fast on the first query, but slows down terribly on the other one. I tried to add the COLLATE statement followed by different encodings, but it doesn’t work. Then I tried to wrap this query into SELECT * FROM ( query ) AS t1 and throw the ORDER BY outside the (), but this wont work neither. The query is as slow as it was. I don’t have any ideas how to fix this.

  • 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-05-17T18:34:42+00:00Added an answer on May 17, 2026 at 6:34 pm

    You need an extra index on rel_pl_es:

    create index idx2 on rel_pl_es( espid,polid);
    

    For the second query, the existing index does not work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem. I do this query in a node.js server using
I'm trying to write quite strange query and i'm having problem with if statement,
I have a strange performance problem with a query used to create a filter
This is a strange problem that I am having with WCF trying to send
I have a strange behavior trying to execute a query declaring ObjectQuery MergeOption to
I have very strange problem with mySQL and simple query with simple index. I
I have strange problem on my pc/server. I run query such as Select field1,
I have been trying to track down a problem with a query I have.
I have a strange problem this time. I've got a masking database setup that
I have a very strange problem with one of my db tables. I have

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.