Hi @ellasbubbles,
I had a look at your screenshot and I was able to replicate that query. Although, it doesn’t take 60s+ on my end, I’ll try to explain what’s happening there.
Regarding caching and repetitive fetches. The query runs 1 time per each new image. As of WordPress 6.1 the WP_Query calls are cached by default, unless explicitly requested not to cache. So those queries should be performing well. If there’s excessive use on the database, the query time can stack up, but my plugin is not the root cause of the slowness here.
Now, why do we even need those in the first place, right? The queries originate from RankMath Images SEO module. If you have that enabled in Rank Math and are using the %filename%
attribute in either the title or the alt value for the image, my plugin will need to find the original file name for offloaded images. Hence, the query to find the original image post and get the title.
You can remove this functionality by removing the %filename%
attribute from RankMath Images SEO module, and this will remove the extra query. You can also comment out the add_filter( 'rank_math/replacements', array( $this, 'fix_file_name_replacement' ), 10, 2 );
line in my plugin in file app/integrations/class-rank-math.php
on line 41. However, it will break the %filename%
functionality in RankMath due to the way Cloudflare Image URLs are formed. So it’s just easier to remove the attribute from RankMath, if you absolutely must get rid of the query.
In all my tests, this did not add any noticeable time to the page load (within 0.0001 seconds per query). However, I’m always open to suggestions if you have any ideas on how to make this query more performant or improve this functionality in any way.
Best regards,
Anton