• Hi,

    I have been having some terrible issues with searching for properties in the WP admin dashboard with the Property Hive plugin but I discovered the cause of the drastic slowdown is in fact the ACF: Better Search plugin which also runs on WP admin queries as well.

    The query being added by this plugin looks like this:

    SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.ID
    FROM wp_posts
    INNER JOIN wp_postmeta AS a
    ON ( a.post_id = wp_posts.ID )
    LEFT JOIN wp_postmeta AS b
    ON ( (( b.post_id = a.post_id ))
    AND (( b.meta_key LIKE CONCAT( ‘\_’, a.meta_key ) )) )
    LEFT JOIN wp_posts AS c
    ON ( ( c.post_name = b.meta_value )
    AND ( c.post_type = ‘acf-field’ )
    AND (( c.post_content LIKE ‘%:”text”%’ )
    OR ( c.post_content LIKE ‘%:”textarea”%’ )
    OR ( c.post_content LIKE ‘%:”wysiwyg”%’ )) )
    LEFT JOIN wp_postmeta AS ph_property_filter_meta_address_concatenated
    ON wp_posts.ID = ph_property_filter_meta_address_concatenated.post_id
    AND ph_property_filter_meta_address_concatenated.meta_key = ‘_address_concatenated’
    LEFT JOIN wp_postmeta AS ph_property_filter_meta_reference_number
    ON wp_posts.ID = ph_property_filter_meta_reference_number.post_id
    AND ph_property_filter_meta_reference_number.meta_key = ‘_reference_number’
    LEFT JOIN wp_postmeta AS ph_property_filter_meta_owner_details
    ON wp_posts.ID = ph_property_filter_meta_owner_details.post_id
    AND ph_property_filter_meta_owner_details.meta_key = ‘_owner_details’
    LEFT JOIN wp_postmeta AS ph_property_filter_meta_imported_ref
    ON wp_posts.ID = ph_property_filter_meta_imported_ref.post_id
    AND ph_property_filter_meta_imported_ref.meta_key LIKE ‘\_imported\_ref\_%’
    WHERE 1=1
    AND ( ( ( b.meta_id IS NOT NULL )
    AND ( c.ID IS NOT NULL )
    AND ( a.meta_value LIKE ‘%Davy%’ )
    AND ( a.meta_value LIKE ‘%Road%’ ) )
    OR ( ( ( (wp_posts.post_title LIKE ‘%Davy%’)
    OR (ph_property_filter_meta_imported_ref.meta_value = ‘Davy Road’)
    OR (ph_property_filter_meta_address_concatenated.meta_value LIKE ‘%Davy%’)
    OR (ph_property_filter_meta_reference_number.meta_value LIKE ‘Davy Road%’)
    OR (ph_property_filter_meta_owner_details.meta_value LIKE ‘%Davy%’) ) )
    AND ( ( (wp_posts.post_title LIKE ‘%Road%’)
    OR (ph_property_filter_meta_imported_ref.meta_value = ‘Davy Road’)
    OR (ph_property_filter_meta_address_concatenated.meta_value LIKE ‘%Road%’)
    OR (ph_property_filter_meta_reference_number.meta_value LIKE ‘Davy Road%’)
    OR (ph_property_filter_meta_owner_details.meta_value LIKE ‘%Road%’) ) ) ) )
    AND ((wp_posts.post_type = ‘property’
    AND (wp_posts.post_status = ‘publish’
    OR wp_posts.post_status = ‘acf-disabled’
    OR wp_posts.post_status = ‘future’
    OR wp_posts.post_status = ‘draft’
    OR wp_posts.post_status = ‘pending’
    OR wp_posts.post_status = ‘private’)))
    ORDER BY (CASE
    WHEN wp_posts.post_title LIKE ‘%Davy Road%’
    THEN 1
    WHEN wp_posts.post_title LIKE ‘%Davy%’
    AND wp_posts.post_title LIKE ‘%Road%’
    THEN 2
    WHEN wp_posts.post_title LIKE ‘%Davy%’
    OR wp_posts.post_title LIKE ‘%Road%’
    THEN 3
    WHEN wp_posts.post_excerpt LIKE ‘%Davy Road%’
    THEN 4
    WHEN wp_posts.post_content LIKE ‘%Davy Road%’
    THEN 5
    ELSE 6 END), wp_posts.post_date DESC
    LIMIT 0, 100

    joins wp_postmeta multiple times for each ACF field
    Multiple LIKE searches which cannot be indexed.
    Multiple OR blocks

    All of these are very expensive, especially for large datasets like properties with hundreds of meta fields.

    Is there a way to prevent these heavy expensive queries being run in the WP Admin dashboard when they are not really needed?

    We use this plugin mainly for frontend searches for relevant blogs etc?

    The default WP Admin search is fine as it is.

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @philsola,

    First of all, please accept my apologies for the long delay in responding. I’m currently catching up on all forum threads.

    Looking at the SQL query you provided, the slowness is unfortunately a result of how WordPress and ACF handle metadata. When searching through specific ACF field types, the plugin has to perform complex JOIN operations and precise filtering to ensure it’s looking at the right data. With a large database, this naturally puts a heavy load on the server.

    There is a way to speed this up significantly:

    Please try enabling Lite mode in the plugin settings.

    In Lite mode, the plugin stops differentiating between specific field types and performs a much simpler, global search across the metadata. This drastically simplifies the SQL query, removes many of the complex joins, and should result in much faster search times even with a large number of properties.

    Give it a go and let me know if you see a performance improvement!

    Best,
    Mateusz

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.