Home > other >  SQL query optimization taking lot of time in execution
SQL query optimization taking lot of time in execution

Time:07-20

enter image description here

enter image description here

We have two tables one is properties and another one is property meta when we are getting data from one table "properties" , query only take less then one second in execution but when we are use join to get the data using bellow query from both tables its taking more then 5 second to fetch the data although we have only 12000 record in the tables , i think there is an issue in the sql query any help or suggestion will be appreciated.

SELECT 
        u.id, 
        u.property_title, 
        u.description, 
        u.city, 
        u.area,
        u.address, 
        u.slug, 
        u.latitude, 
        u.longitude, 
        u.sync_time, 
        u.add_date, 
        u.is_featured, 
        u.pre_construction, 
        u.move_in_date,
        u.property_status, 
        u.sale_price, 
        u.mls_number, 
        u.bedrooms, 
        u.bathrooms, 
        u.kitchens, 
        u.sub_area, 
        u.property_type, 
        u.main_image, 
        u.area_size as land_area, 
        pm7.meta_value as company_name, 
        pm8.meta_value as virtual_tour, 
        u.year_built, 
        u.garages 
    FROM 
        tbl_properties u 
            LEFT JOIN tbl_property_meta pm7 
                ON u.id = pm7.property_id 
            LEFT JOIN tbl_property_meta pm8 
                ON u.id = pm8.property_id 
    WHERE 
            u.status = 1 
        AND (pm7.meta_key = 'company_name') 
        AND (pm8.meta_key = 'virtual_tour') 
        AND (
                (
                        (   u.city = 'Delta' 
                        OR  u.post_code LIKE '           
  • Related