#26744 closed enhancement (fixed)
Twenty Fourteen: reduce the number of queries when there is no featured post
Reported by: | Chouby | Owned by: | lancewillett |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | 3.8 |
Component: | Bundled Theme | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
Thanks to the transient used by Feature_Content::get_featured_post_ids, the featured post ids are not queried at each page load. The transient is however never set if there is no featured post resulting in performance loss.
Attachments (6)
Change History (17)
#2
@
11 years ago
- Keywords needs-testing added
- Milestone changed from Awaiting Review to 3.9
If we trust our cache busting enough, we could just put those sticky post ids in the transient, if there are no tagged posts. ;)
#4
@
10 years ago
- Keywords needs-refresh added
- Milestone changed from Future Release to 4.0
@obenland Want to look at this one again?
#5
@
10 years ago
@obenland's patch works great for me.
No featured posts:
26 queries dropped to 24 queries with the patch
1 featured post:
54 queries dropped to 29 queries
Minor gain when there are no featured posts, significant gain with featured posts.
This ticket was mentioned in IRC in #wordpress-themes by obenland. View the logs.
10 years ago
#7
follow-up:
↓ 8
@
10 years ago
- Keywords needs-refresh removed
Saw a problem in testing: $featured = get_posts( array() );
the variable assignment here should be $featured_ids
instead, right?
#8
in reply to:
↑ 7
@
10 years ago
Replying to lancewillett:
the variable assignment here should be
$featured_ids
instead, right?
Correct, good catch.
#9
@
10 years ago
This is my testing results with the updated patch:
With no featured posts:
34 queries on first load, down to 26 queries on second load
With featured posts:
43 queries on first load down to 35 on second load
(Using Debug Bar plugin with define( 'SAVEQUERIES', true );
in my wp-config.php file.)
#10
@
10 years ago
- Owner set to lancewillett
- Resolution set to fixed
- Status changed from new to closed
In 29174:
#11
@
10 years ago
hi Lance, all,
did you consider to use WP_Query in combination with update_post_thumbnail_cache() instead of get_posts? I wonder why update_post_thumbnail_cache() is a bit obscure and not documented in the Codex, is it still recommended? Read about it in #19949 and looks like a great way to reduce queries when there are many thumbnails to get at once. With 6 featured posts and 6 thumbnails could save 10 queries.
However, it would require to change something also in Jetpack.
according to my tests, the proposed patch suppresses 6 queries