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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:41:39+00:00 2026-05-16T20:41:39+00:00

I am using MySQL database. When I execute a query which the main table(20

  • 0

I am using MySQL database. When I execute a query which the main table(20 thousands of rows) is joined with the other 5 tables, it takes 90 seconds to return me the result. I then added indices into each of the criteria(where clause). Then the execution time drops from 90 seconds to 45 seconds and then I tried to select only necessary fields instead of all(*), it takes 25 seconds. What should I do to make it drop to less than 5 seconds or even one second?

SELECT
ap.propertyid, ap.type_market, 
ap.market_sale_price, ap.sale_from, ap.sale_until, ap.property_salepsf, 
ap.rent_from, ap.property_rent_until, ap.property_rentpsf, ap.title, 
ap.street, ap.suburbs, ap.state, ap.bedrooms, ap.bathrooms, ap.carport, 
ap.buildup_area, ap.builtup_area_from, ap.builtup_area_to, 
ap.land_area, ap.land_area_from, ap.land_area_to, 
ap.status AS prop_status, ap.datecreate AS uploadedOn, type_property.name, (
 SELECT name 
 FROM gallery 
 WHERE
 propertyid = ap.propertyid
 ORDER BY frontpage
 LIMIT 0, 1
) AS picture, 
uom_mst.uom_shortcode,
agent_profile.person, agent_profile.mobile, agent_profile.electronicmail, agent_profile.agent_pix, agent_profile.agent_pix_crop,
country.country_currency_html AS currency,
owner_profile.oname, owner_profile.omobile, owner_profile.oemail
FROM agentproperty ap
LEFT JOIN agent_profile ON (ap.agentid = agent_profile.agentid)
LEFT JOIN type_property ON (ap.type_property = type_property.rid)
LEFT JOIN uom_mst ON (ap.property_bua_uom = uom_mst.uom_id)
LEFT JOIN country ON (ap.property_ctry = country.country_id)
LEFT JOIN owner_profile ON (ap.propertyid = owner_profile.propertyid)
WHERE
ap.status = 'active' AND 
agent_profile.status = 'active' AND 
ap.property_type = '1' AND 
getCompanyID(ap.propertyid) = '001' AND 
ap.agentid = '100010001'
GROUP BY ap.propertyid
ORDER BY ap.datecreate DESC
LIMIT 200, 10
  • 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-16T20:41:39+00:00Added an answer on May 16, 2026 at 8:41 pm

    Run EXPLAIN PLAN on your query and see what MySQL says about it.

    Make sure that all the columns involved in the JOINs have indexes associated with them.

    Six tables in a JOIN is a lot of work for a database. I’d recommend seeing if reordering the JOINs has any effect. If you order the JOINs from most restrictive to least you might cut down on the work needed.

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

Sidebar

Related Questions

I'm building a wepage in php using MySQL as my database. Which way is
My MySQL database contains several tables using different storage engines (specifically myisam and innodb).
In PHP, which is quicker; using include('somefile.php') or querying a MySQL database with a
Consider the following database tables: Table messages with 13,000,000 rows (one row per message).
I'm looking at implementing a failover mechanism for a MySQL database using MySQL Proxy
I've connected to a MySQL database using Perl DBI. I would like to find
I am trying to connect to a remote MySQL database using Visual C# 2008
How can I restore a mysql database that was dropped using a drop database
Are there any good tools for visualising a pre-existing database schema? I'm using MySQL
How do I connect to the database(MYSQL) in connection bean using JSF to retrieve

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.