I’m having the same issue as Lletnek where there are the same duplicate queries for get_page_by_path
on some of the pages on our website. I have got the queries down to 2/3 on most pages using Memcached Redux and WP_Object
cache. The goal is 0 queries. It seems strange that WP doesn’t cache the get_page_by_path
or the get_posts
or get_pages
. If it does it’s a very short expiration.
The query in question is
SELECT ID, post_name, post_parent, post_type
FROM poststable
WHERE post_name IN ('slug')
AND post_type IN ('page','attachment')
The callers are
get_page_by_path()
wp-includes/post.php:4255-
WP_Query->parse_query()
wp-includes/query.php:1799
WP_Query->get_posts()
wp-includes/query.php:2480
WP_Query->query()
wp-includes/query.php:4006
WP->query_posts()
wp-includes/class-wp.php:608
WP->main()
wp-includes/class-wp.php:726
wp()
wp-includes/functions.php:952
and
WP_Query->get_posts()
wp-includes/query.php:3613-
WP_Query->query()
wp-includes/query.php:4006
WP->query_posts()
wp-includes/class-wp.php:608
WP->main()
wp-includes/class-wp.php:726
wp()
wp-includes/functions.php:952
I looked into use_verbose_page_rules
that John mentioned in the linked post but I couldn’t find out much about it. We are using permalinks like /sample-post/
.
I have also tried setting a base for the category permalinks but it hasn’t changed anything. We don’t even have any posts or categories just pages.
So my question is How can I remove the second get_page_by_path
query and/or then cache the results?