wp_enqueue_media()

edited June 2024 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.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.