Title: Core code caching issue w/ nav?
Last modified: August 20, 2016

---

# Core code caching issue w/ nav?

 *  [daveagp](https://wordpress.org/support/users/daveagp/)
 * (@daveagp)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/core-code-caching-issue-w-nav/)
 * Hi,
 * Every time a page view occurs, wordpress is sending a complex non-ndexed query
   like
 * # Query_time: 0 Lock_time: 0 Rows_sent: 320 Rows_examined: 1608
    SELECT post_id,
   meta_key, meta_value FROM wp_postmeta WHERE post_id IN (2366,2363,4066,…etc);
 * I noticed this using log-queries-not-using-indexes in mysql.
 * The pertinent call stack is:
 * wp_get_nav_menu_items(3) in nav-menu.php (around line 495) calls
    get_posts in
   post.php (around line 1461) calls WP-Query->query in query.php (around line 2941)
   calls WP-Query->get_posts in query.php (around line 2767) calls update_post_caches
   in post.php (around line 4454) calls update_postmeta_cache in post.php (around
   line 4474) calls update_meta_cache in meta.php (around 560) which makes the nasty
   SELECT statement
 * The SELECT statement is basically getting all the info from wp_postmeta for menu
   items whose post_id there has term_taxonomy_id = 3 in wp_term_relationships.
 * In other words, it’s getting some metadata corresponding to the menu bar.
 * But, why is the cache updated on every single page view? I have very little clue
   how the cache works (I’m starting to read about it) and that’s why I’m writing
   here. All I can say is that the “cache_results” is automatically turned on inside
   of the call to WP-Query->get_posts around line 1970. That’s great, but why might
   the cache get refreshed on every single page view?
 * What I want is to avoid that this complex SQL call is made on every single page
   view.

Viewing 1 replies (of 1 total)

 *  Thread Starter [daveagp](https://wordpress.org/support/users/daveagp/)
 * (@daveagp)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/core-code-caching-issue-w-nav/#post-3185958)
 * xref: [http://wordpress.stackexchange.com/questions/72401/repeated-nav-bar-queries-failing-to-be-cached](http://wordpress.stackexchange.com/questions/72401/repeated-nav-bar-queries-failing-to-be-cached)

Viewing 1 replies (of 1 total)

The topic ‘Core code caching issue w/ nav?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [daveagp](https://wordpress.org/support/users/daveagp/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/core-code-caching-issue-w-nav/#post-3185958)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
