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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:25:31+00:00 2026-05-15T02:25:31+00:00

After learning how to do MySQL Full-Text search, the recommended solution for multiple tables

  • 0

After learning how to do MySQL Full-Text search, the recommended solution for multiple tables was OR MATCH and then do the other database call. You can see that in my query below.

When I do this, it just gets stuck in a “busy” state, and I can’t access the MySQL database.

SELECT 
 a.`product_id`, a.`name`, a.`slug`, a.`description`, b.`list_price`, b.`price`, c.`image`, c.`swatch`, e.`name` AS industry, 
 MATCH( a.`name`, a.`sku`, a.`description` ) AGAINST ( '%s' IN BOOLEAN MODE )     AS relevance 
FROM 
 `products` AS a LEFT JOIN `website_products` AS b 
  ON (a.`product_id` = b.`product_id`) 
 LEFT JOIN ( SELECT `product_id`, `image`, `swatch` FROM `product_images` WHERE `sequence` = 0) AS c 
  ON (a.`product_id` = c.`product_id`) 
 LEFT JOIN `brands` AS d 
  ON (a.`brand_id` = d.`brand_id`) 
 INNER JOIN `industries` AS e ON (a.`industry_id` = e.`industry_id`) 
WHERE 
 b.`website_id` = %d
 AND b.`status` = %d
 AND b.`active` = %d 
 AND MATCH( a.`name`, a.`sku`, a.`description` ) AGAINST ( '%s' IN BOOLEAN MODE ) 
  OR MATCH ( d.`name` ) AGAINST ( '%s' IN BOOLEAN MODE )
GROUP BY a.`product_id` 
ORDER BY relevance DESC 
LIMIT 0, 9 

Any help would be greatly appreciated.


EDIT

All the tables involved are MyISAM, utf8_general_ci.

Here’s the EXPLAIN SELECT statement:

id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY a ALL NULL NULL NULL NULL 16076 Using temporary; Using filesort
1 PRIMARY b ref product_id product_id 4 database.a.product_id 2  
1 PRIMARY e eq_ref PRIMARY PRIMARY 4 database.a.industry_id 1  
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 23261  
1 PRIMARY d eq_ref PRIMARY PRIMARY 4 database.a.brand_id 1 Using where
2 DERIVED product_images ALL NULL NULL NULL NULL 25933 Using where

I don’t know how to make that look neater — sorry about that


UPDATE

it returns the query after 196 seconds (I think correctly). The query without multiple tables takes about .56 seconds (which I know is really slow, we plan on changing to solr or sphinx soon), but 196 seconds??

If we could add a number to the relevance if it was in the brand name ( d.name ), that would also work

  • 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-15T02:25:31+00:00Added an answer on May 15, 2026 at 2:25 am

    I found 2 things slowing down my query drastically and fixed them.

    To answer the first problem, it needed parentheses around the entire “MATCH AGAINST OR MATCH AGAINST”:

    WHERE 
        b.`website_id` = %d
        AND b.`status` = %d
        AND b.`active` = %d 
        AND ( 
            MATCH( a.`name`, a.`sku`, a.`description` ) AGAINST ( '%s' IN BOOLEAN MODE ) 
            OR MATCH ( d.`name` ) AGAINST ( '%s' IN BOOLEAN MODE )
        )
    

    I didn’t understand how to use EXPLAIN SELECT, but it helped quite a bit, so thank you! This reduced that first number 16076 rows to 143. I then noticed the other two with over 23 and 25 thousand rows. That was cause from this line:

    LEFT JOIN ( SELECT `product_id`, `image`, `swatch` FROM `product_images` WHERE `sequence` = 0) AS c 
        ON (a.`product_id` = c.`product_id`)
    

    There was a reason I was doing this in the first place, which then changed. When I changed it, I didn’t realize I could do a normal LEFT JOIN:

    LEFT JOIN `product_images` AS c 
        ON (a.`product_id` = c.`product_id`)
    

    This makes my final query like this: (and MUCH faster went from the 196 seconds to 0.0084 or so)

    SELECT 
        a.`product_id`, a.`name`, a.`slug`, a.`description`, b.`list_price`, b.`price`, 
        c.`image`, c.`swatch`, e.`name` AS industry, 
        MATCH( a.`name`, a.`sku`, a.`description` ) AGAINST ( '%s' IN BOOLEAN MODE ) AS relevance 
    FROM 
        `products` AS a LEFT JOIN `website_products` AS b 
            ON (a.`product_id` = b.`product_id`) 
        LEFT JOIN `product_images` AS c 
            ON (a.`product_id` = c.`product_id`) 
        LEFT JOIN `brands` AS d 
            ON (a.`brand_id` = d.`brand_id`) 
        INNER JOIN `industries` AS e 
            ON (a.`industry_id` = e.`industry_id`) 
    WHERE 
        b.`website_id` = %d
        AND b.`status` = %d
        AND b.`active` = %d
        AND c.`sequence` = %d
        AND ( 
            MATCH( a.`name`, a.`sku`, a.`description` ) AGAINST ( '%s' IN BOOLEAN MODE ) 
            OR MATCH( d.`name` ) AGAINST( '%s' IN BOOLEAN MODE ) 
        )
    GROUP BY a.`product_id` 
    ORDER BY relevance DESC 
    LIMIT 0, 9
    

    Oh, and even before I was doing a full text search with multiple tables, it was taking about 1/2 a second. This is much improved.

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

Sidebar

Ask A Question

Stats

  • Questions 457k
  • Answers 457k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The primary (brute force) alternative looks like: v = log(exp(log_a)… May 15, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer It depends upon your requirements, whether you want to execute… May 15, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer When a TextBox is in multiline mode, it's rendered as… May 15, 2026 at 10:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.