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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:29:49+00:00 2026-05-16T21:29:49+00:00

I have a problem with a quite slowish MYSQL query. I’m building an AJAX

  • 0

I have a problem with a quite slowish MYSQL query. I’m building an AJAX menu with PHP and performance is really an issue. The query takes about 0,5 sec to complete, and i don’t know how to optimize it.

The SQL query :

SELECT M.nom_mat, M.id_mat, M.rang, SC.nom_sous_cat, SC.id_sous_cat, C.nom_cat,M.id_cat
FROM besson_mat M
LEFT OUTER JOIN besson_lien_mat LM ON M.id_mat = LM.id_mat
LEFT OUTER JOIN besson_sous_cat SC ON SC.id_sous_cat = LM.id_sous_cat
LEFT OUTER JOIN besson_cat C ON C.id_cat = SC.id_cat
WHERE M.en_ligne = '1'
AND M.lg = 'fr'
AND (
M.id_cat = '28'
OR M.id_cat = '29'
)
OR (
SC.id_sous_cat = '37'
OR SC.id_sous_cat = '42'
OR SC.id_sous_cat = '43'
OR SC.id_sous_cat = '44'
)
ORDER BY C.id_cat ASC , SC.id_sous_cat ASC , M.rang ASC

Thanks for your help, I’ll update my question if you need more details.

FINAL EDIT

The extra parentheses in the WHERE clause were the cause of the problem. Now my Query takes about 0.0718 sec to complete, thank you so much.

  • 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-16T21:29:49+00:00Added an answer on May 16, 2026 at 9:29 pm

    Typically you might consider putting indexes on any of the columns used in your JOINS, WHERE clauses, and ORDER BY clauses.

    If that doesn’t help, use your database development interface to do an explain plan on the query to see where it’s bogging down.

    You might try putting the results of your Explain Plan here.

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

Sidebar

Related Questions

Hi there I'm quite new to PHP I have this problem: I would like
I have quite problem with deploying on heroku. Really don't no why it doesn't
I have a problem that is quite simple to understand, but for me it
I have problem SIMILAR to preventing form data reposting, but not quite the same
I have quite a problem concerning the use of relational database concepts in Delphi
My problem is quite simple: I have a 400MB file filled with 10,000,000 lines
I have a problem that I'm working on for quite some time now. I
I have a problem with Javascript that keeps bugging me for quite a while
I'm quite new here. I have a problem with the new iOS 5.1 slide-in
I have this quite popular problem, but have failed to find a solution that

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.