wp_enqueue_media()

edited June 11 in Menu / Mega menu

Hello,

I am getting some very slow MYSQL queries and they are all made by

  1. wp_enqueue_media()

I assume when you open a page/post/PRODUCT it asks wordpress to show the featured image/ images.


Is there a fix to make this faster and not to be a slow query.


The site is on a Server with 10 GB RAM so it definitely should work faster and has WO ROCKET and Perfematters cachings enabled.

the website is bettervision.eu

Please assist :)

Comments

  • Hey,

    Please send us the WordPress dashboard and FTP access privately through the contact form, which is on the right side at https://themeforest.net/user/muffingroup#contact and we will check what might be the reason.

    Notice!

    Please attach a link to this forum discussion.

    Sending incorrect or incomplete data will result in a longer response time.

    Therefore, please ensure that the data you send are complete and correct.

    Thanks

  • details are sent. Thank you


    any speed optimization / mysql query optimizations are welcome.


    Thank you.

  • I thoroughly checked the site, and the issue is with the `attachment_url_to_postid()` function, which unfortunately performs very slowly on servers with very large databases.

    https://core.trac.wordpress.org/ticket/41281There are two solutions for this:1. Enable indexing in the database. You can find a description of how to do this below:

    https://core.trac.wordpress.org/ticket/41281#Solution2. Disable the use of this function in the theme. However, this is not recommended because this function is responsible for retrieving image metadata such as width, height, and alt.


    Best regards

  • Hello,


    Thank you for the details answer. This was more than enough for me to look for a solution.


    The indexing option looked great and indeed made miracles to the website. Now there are NO slow queries and the site is loading very well on my end. I am happy with the solution you suggested.


    I found a free plugin that made miracles in my case. I am not sure if I show it here but indeed it worked fine for me.

    STEPS

    1- make back up of the database

    2- optimize/convert the tables to the latest version (the plugin suggests this if you need it)

    3- add high performance keys to the tables with most rows and size (the plugin suggests which tables)


    Thank you for the assistance. Have a nice day :)

  • You are welcome.

    If you have any other questions or problems, feel free to ask.


    Best regards

Sign In or Register to comment.