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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:41:20+00:00 2026-05-23T11:41:20+00:00

I would like to know if there is a way to optimize this query

  • 0

I would like to know if there is a way to optimize this query :

SELECT
    jdc_organizations_activities.*,
    jdc_organizations.orgName, 
    CONCAT(jos_hpj_users.firstName, ' ', jos_hpj_users.lastName) AS nameContact  
FROM jdc_organizations_activities
LEFT JOIN jdc_organizations ON jdc_organizations_activities.organizationId =jdc_organizations.id
LEFT JOIN jos_hpj_users ON jdc_organizations_activities.contact = jos_hpj_users.userId
WHERE jdc_organizations_activities.status LIKE 'proposed'  
ORDER BY jdc_organizations_activities.creationDate DESC LIMIT 0 , 100 ;

Tables Info

Now When i see the query log :

 Query_time: 2  
 Lock_time: 0  
 Rows_sent: 100  
 Rows_examined: **1028330**

Query Profile :

enter image description here

2) Should i put indexes on the tables having in mind that there will be a lot of inserts and updates on those tables .

From Tizag Tutorials :

Indexes are something extra that you
can enable on your MySQL tables to
increase performance,cbut they do have
some downsides. When you create a new
index MySQL builds a separate block of
information that needs to be updated
every time there are changes made to
the table. This means that if you
are constantly updating, inserting and
removing entries in your table this
could have a negative impact on
performance.

Update after adding indexes and removing the lower() , group by and the wildcard

Time: 0.855ms

enter image description here

  • 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-23T11:41:20+00:00Added an answer on May 23, 2026 at 11:41 am

    Add indexes (if you haven’t) at:

    Table: jdc_organizations_activities

    • simple index on creationDate
    • simple index on status
    • simple index on organizationId
    • simple index on contact

    And rewrite the query by removing call to function LOWER() and using = or LIKE. It depends on the collation you have defined for this table but if it’s a case insensitive one (like latin1), it will still show same results. Details can be found at MySQL docs: case-sensitivity

    SELECT a.*
         , o.orgName
         , CONCAT(u.firstName,' ',u.lastName) AS nameContact  
    
    FROM jdc_organizations_activities AS a
      LEFT JOIN jdc_organizations AS o
        ON a.organizationId = o.id 
      LEFT JOIN jos_hpj_users AS u
        ON a.contact = u.userId
    
    WHERE a.status LIKE 'proposed'     --- or (a.status = 'proposed')
    
    ORDER BY a.creationDate DESC 
    LIMIT 0 , 100 ;
    

    It would be nice if you posted the execution plan (as it is now) and after these changes.


    UPDATE

    A compound index on (status, creationDate) may be more appopriate (as Darhazer suggested) for this query, instead of the simple (status). But this is more guess work. Posting the plans (after running EXPLAIN query) would provide more info.

    I also assumed that you already have (primary key) indexes on:

    • jdc_organizations.id
    • jos_hpj_users.userId
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know if there is any way to add custom behaviour
I would like to know if there is some way to share a variable
I would like to know if there is a way to disable automatic loading
I would like to know if there is a way to keep the session
I would like to know if there is any way I can apply 100%
I would like to know if there is any way to return an char
I would like to know if there is a way to take create a
I would like to know if there is any way that I could build
I would like to know if there is a way to test whenever thread
and I would like to know if there is any way to stop a

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.