Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#6746 closed defect (bug) (fixed)

can't we cache _get_post_ancestors()?

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by:
Milestone: 2.5.1 Priority: normal
Severity: normal Version: 2.5
Component: Optimization Keywords:
Focuses: Cc:


It seems there's a reason for not doing so, but when your site has a hundred static pages, displaying the pages widget readily takes a second or more...

Attachments (1)

get_permalink_cached.diff (1.6 KB) - added by filosofo 16 years ago.

Download all attachments as: .zip

Change History (7)

#1 @Denis-de-Bernardy
16 years ago

figures for a site with 90 static pages:

@ init hook: 7 queries - 0.160 seconds
@ template_redirect hook: 11 queries - 0.183 seconds
@ wp_footer hook: 153 queries - 0.403 seconds

the 153 queries (almost all related to _get_post_ancestors()) take as much as a second every now and then...

#2 @Denis-de-Bernardy
16 years ago

further investigation leads me to identify get_permalink() as the likely culprit for the insane number of queries.

brings me to a thought: isn't reasonable to assume that, if at one point another a page gets queried, there's a 99% change that get_permalink() will get called? if so, it would make sense to get all the ancestors and their details whenever they're not in the cache already.


#3 @filosofo
16 years ago

I've attached a patch that adds object caching to get_permalink. Does that help reduce the queries?

#4 @ryan
16 years ago

See also #6702

#5 @Denis-de-Bernardy
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

fixed via the other ticket. thanks!


#6 @Nazgul
16 years ago

  • Milestone set to 2.5.1
Note: See TracTickets for help on using tickets.