MySQL Forums
Forum List  »  General

Re: Sql query involving subqueries in where clause
Posted by: Rick James
Date: March 20, 2014 06:27PM

Redundant code --> slow
IN ( SELECT ... ) --> slow

Suggest
CREATE TABLE foo (
    INDEX(s_address),
    INDEX(p_address)
)
select  s.name,
        s.address AS s_address,
        p.address AS p_address,
        levenshtein(s.address, p.address) as M
    from  student as s
    join  professor as p
    where levenshtein(s.address, s.address) <=10;
Then use `foo` three times in the the real query.
(And DROP TABLE foo when finished.)

Also, use UNION ALL or UNION DISTINCT, whichever is appropriate.

Options: ReplyQuote


Subject
Written By
Posted
Re: Sql query involving subqueries in where clause
March 20, 2014 06:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.