Jump to content

MULITPLE JOIN QUERY RUNS SO SLOW -


jwwceo

Recommended Posts

Hey All,

 

I have a site where I am running a few simple queries, such as find by color, find by keyword, etc.

 

I am trying to implement a "search by anything" where a user can enter a term into a text box and get results from any number of fields.

 

It works, but it takes forever to run...like maybe 1-3 minutes. And then after that query is run, the site runs slow unless I close the browser window and open it again. Then all is fine. Its like the query eats all the memory....

 

Has anyone ever heard of this???

 

Here is the query.

 

$dataP = mysql_query("SELECT *
FROM shirts
INNER JOIN shirtcolors on shirtcolors.shirt_id = shirts.shirt_id
INNER JOIN colors ON colors.color_id = shirtcolors.color_id
INNER JOIN shirtkeywords ON shirtkeywords.shirt_id = shirts.shirt_id
INNER JOIN keywords ON shirtkeywords.keyword_id = keywords.keyword_id
WHERE(
colors.color = '$search'
OR keywords.keyword like '%$search%'
OR shirts.name like '%$search%'
OR shirts.keywordlist like '%$search%')
AND active='true' AND approved='1'
GROUP BY shirts.shirt_id ORDER BY shirts.$field $direction
LIMIT $from, $max_results");

 

James

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.