HomePage Forums Traveler Query takes a lot of time : STHotel->get_unavailability_hotel()

This topic contains 2 replies, has 2 voices, and was last updated by  Bryan 4 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24661

    Below query takes a lot of time (37s). Can you solve this issue???

    STHotel->get_unavailability_hotel()
    ::::::::::::::::

    SELECT ID, hotel_id, count(hotel_id) as total_room 
    FROM ( 
    SELECT ID, wp_postmeta.meta_value as adult_number, st_meta1.meta_value as children_number, st_meta3.meta_value as number_room, st_meta2.meta_value as hotel_id 
    FROM wp_posts JOIN wp_postmeta on wp_postmeta.post_id=wp_posts.ID and wp_postmeta.meta_key=’adult_number’ JOIN wp_postmeta as st_meta1 on st_meta1.post_id=wp_posts.ID and st_meta1.meta_key=’children_number’ JOIN wp_postmeta as st_meta3 on st_meta3.post_id=wp_posts.ID and st_meta3.meta_key=’number_room’ JOIN wp_postmeta as st_meta2 on st_meta2.post_id=wp_posts.ID and st_meta2.meta_key=’room_parent’ where 1=1 
    AND post_type=’hotel_room’ 
    AND wp_posts.ID IN ( 
    SELECT room_id from( 
    SELECT room_id, sum(room_num_search) AS total_booked, room.number_room 
    FROM wp_st_order_item_meta 
    INNER JOIN wp_hotel_room AS room
    ON room.post_id = wp_st_order_item_meta.room_id 
    WHERE 1 = 1 
    AND ( ( check_in_timestamp <= 1536710400 
    AND check_out_timestamp >= 1536710400 ) 
    OR ( check_in_timestamp >= 1536710400 
    AND check_in_timestamp <= 1536796800 ) ) 
    AND st_booking_post_type = ‘st_hotel’ 
    AND STATUS NOT IN ( ‘trash’, ‘canceled’, ‘wc-cancelled’ ) 
    GROUP BY room_id Having room.number_room – total_booked < 1 ) as booked_table ) 
    OR wp_posts.ID IN ( 
    SELECT post_id 
    FROM wp_st_room_availability 
    WHERE 1 = 1 
    AND ( check_in >= 1536710400 
    AND check_out <= 1536796800 
    AND status = ‘unavailable’ ) ) 
    OR wp_postmeta.meta_value < 1 
    OR st_meta3.meta_value < 1 
    GROUP BY wp_posts.ID ) as room_data 
    GROUP BY hotel_id 
    HAVING total_room >= ( 
    SELECT count(post_id) 
    FROM wp_postmeta 
    WHERE meta_key = ‘room_parent’ 
    AND meta_value = hotel_id )

    #24662

    More details about Caller :

    query_posts()
    wp-includes/query.php:98
    WP_Query->query()
    wp-includes/class-wp-query.php:3230
    WP_Query->get_posts()
    wp-includes/class-wp-query.php:2376
    apply_filters_ref_array(‘posts_where’)
    wp-includes/plugin.php:244
    STHotel->_get_where_query()
    wp-content/themes/traveler/inc/class/class.hotel.php:1978
    STHotel->get_unavailability_hotel()
    wp-content/themes/traveler/inc/class/class.hotel.php:2883

    #24746

    Hello

    That query take all data from calendar of every month, year…to display so it run in quite slow.

    We will check and find the way to improve it in future.

    Thank for your understanding.

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘Traveler’ is closed to new topics and replies.