Opened 11 years ago
Closed 10 years ago
#14090 closed defect (bug) (invalid)
the_tags never caches
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0.2 |
Component: | Taxonomy | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
this is what i get every time there is a call to the_tags function:
SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (__POST_ID__) ORDER BY t.name ASC
Of course one query each post! D'oh!
Change History (8)
#2
in reply to:
↑ 1
@
11 years ago
- Cc luctre@… added
Replying to ryan:
If the posts in question weren't fetched with get_posts() then that will happen. Posts fetched with get_posts() will call update_object_term_cache() so that taxonomy for all posts can be retrieved with one query.
Hi ryan,
i have a fresh wp install with only WP File Cache plugin to handle caching, i'm a bit confused, in my home i got this (you can see it uses get_posts()):
12 queries 1. SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10 [0.0012137889862061] require, wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts 2. SELECT FOUND_ROWS() [0.0011308193206787] require, wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts 3. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (141) ORDER BY t.name ASC [0.014594078063965] require, require_once, include, get_template_part, locate_template, load_template, require, post_class, get_post_class, get_the_tags, get_the_terms, wp_get_object_terms 4. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (141) ORDER BY t.name ASC [0.018500804901123] require, require_once, include, get_template_part, locate_template, load_template, require, get_the_tag_list, get_the_term_list, get_the_terms, wp_get_object_terms 5. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (140) ORDER BY t.name ASC [0.0010030269622803] require, require_once, include, get_template_part, locate_template, load_template, require, post_class, get_post_class, get_the_tags, get_the_terms, wp_get_object_terms 6. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (140) ORDER BY t.name ASC [0.00054287910461426] require, require_once, include, get_template_part, locate_template, load_template, require, get_the_tag_list, get_the_term_list, get_the_terms, wp_get_object_terms 7. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (139) ORDER BY t.name ASC [0.00051283836364746] require, require_once, include, get_template_part, locate_template, load_template, require, post_class, get_post_class, get_the_tags, get_the_terms, wp_get_object_terms 8. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (139) ORDER BY t.name ASC [0.00049591064453125] require, require_once, include, get_template_part, locate_template, load_template, require, get_the_tag_list, get_the_term_list, get_the_terms, wp_get_object_terms 9. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (105) ORDER BY t.name ASC [0.00055694580078125] require, require_once, include, get_template_part, locate_template, load_template, require, post_class, get_post_class, get_the_tags, get_the_terms, wp_get_object_terms 10. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (105) ORDER BY t.name ASC [0.0008690357208252] require, require_once, include, get_template_part, locate_template, load_template, require, get_the_tag_list, get_the_term_list, get_the_terms, wp_get_object_terms 11. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (1) ORDER BY t.name ASC [0.00066900253295898] require, require_once, include, get_template_part, locate_template, load_template, require, post_class, get_post_class, get_the_tags, get_the_terms, wp_get_object_terms 12. SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (1) ORDER BY t.name ASC [0.00062394142150879] require, require_once, include, get_template_part, locate_template, load_template, require, get_the_tag_list, get_the_term_list, get_the_terms, wp_get_object_terms
is there something i can check or some plugin i can use to fix it?
#6
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
#7
@
10 years ago
- Cc EPANETWP added
- Resolution invalid deleted
- Status changed from closed to reopened
- Version changed from 3.0 to 3.0.2
Hi guys,
I´ve having a simular issue.
MySQL is giving slow queries like these:
# Sat Dec 4 13:07:33 2010 # Query_time: 2.471577 Lock_time: 0.061732 Rows_sent: 4 Rows_examined: 22 use espaland_wrd3; SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('post_tag') AND tr.object_id IN (1878) ORDER BY t.name ASC # Sat Dec 4 13:07:39 2010 # Query_time: 2.743471 Lock_time: 0.051083 Rows_sent: 1 Rows_examined: 9 use espaland_wrd3; SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category') AND tr.object_id IN (1718) ORDER BY t.name ASC
blueHost is CPU throttling my account becasue of few bunch of queries like that.
#8
@
10 years ago
- Resolution set to invalid
- Status changed from reopened to closed
Please try the support forums: http://wordpress.org/support/
Code somewhere is doing something wrong.
If the posts in question weren't fetched with get_posts() then that will happen. Posts fetched with get_posts() will call update_object_term_cache() so that taxonomy for all posts can be retrieved with one query.