Make WordPress Core

Opened 16 years ago

Closed 11 years ago

#8874 closed enhancement (maybelater)

wp_list_pages consume a lot of memory

Reported by: horaciod's profile horaciod Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Query Keywords: needs-patch
Focuses: performance Cc:

Description

When we use wp_list_pages in installatiosn with lots of pages (in my case 106 with a lot of text inside ) this function use get_pages (posts.php) which has a get_results of the posts completes with a "select *" but only id,post_title, post_parent is needed.
Maybe you can use a nuew option to wp_list_pages or get_pages with the list of fields to retrieve.
I´m making a patch but first i´m studing the code rules of wordpress.
This Affects a wpdtree plugin and other which use get_pages. In my case this select break the connection with mysql in a Shared web server.

Attachments (4)

8874.wp_page_menu.patch (1.1 KB) - added by hakre 16 years ago.
Just found while taking a look into this ticket. wp_page_menu improvements.
8874.patch (4.8 KB) - added by hakre 16 years ago.
new argument: fields.
8874.2.patch (5.2 KB) - added by hakre 16 years ago.
Update patch to have authors describben as well. Link to codex added.
8874.3.patch (5.2 KB) - added by hakre 16 years ago.
Patch contained errors. Fixed.

Download all attachments as: .zip

Change History (19)

#1 follow-up: @mrmist
16 years ago

I'm pretty sure that there's already a ticket floating around with a patch for wp_list_pages. Can't find it just now. I agree with the sentiment though.

#2 in reply to: ↑ 1 @horaciod
16 years ago

Replying to mrmist:

I'm pretty sure that there's already a ticket floating around with a patch for wp_list_pages. Can't find it just now. I agree with the sentiment though.

i've made a search too but nothing found.

#3 @mrmist
16 years ago

  • Keywords needs-patch added
  • Milestone changed from 2.7.1 to 2.8
  • Version set to 2.7

Yep. Must have been another query.

needs a patch so I doubt it will make 2.7.1

#4 @FFEMTcJ
16 years ago

  • Milestone changed from 2.8 to Future Release

#5 @Denis-de-Bernardy
16 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

dup of #8492

#6 @Denis-de-Bernardy
16 years ago

  • Milestone set to Future Release
  • Resolution duplicate deleted
  • Status changed from closed to reopened

re-opening as it's actually a different bug. the two are related though.

@hakre
16 years ago

Just found while taking a look into this ticket. wp_page_menu improvements.

@hakre
16 years ago

new argument: fields.

#7 @hakre
16 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 2.8

patch added, should to the job. set the fields - argument to 'ID, post_title, post_parent'. did work like a charm for me.

cache only works on default '*' set of fields. it can make sense to use the $fields parameters content as part of the cache key and enable caching for certain type of queries as well.

addtionally the docblock has been extended to have a description of all parameters. all but author.

@hakre
16 years ago

Update patch to have authors describben as well. Link to codex added.

@hakre
16 years ago

Patch contained errors. Fixed.

#8 @Denis-de-Bernardy
16 years ago

  • Keywords dev-feedback added

I *think* that this:

wp_cache_set( 'get_pages', $cache, 'posts' );

... is needed.

what is missing and may not necessarily be needed is:

update_post_cache($pages);

that being said, adding such a call will tremendously speed things up when generating permalinks, since it saves one query per missed cache hit.

maybe there is a need for an extra cache group, for use by permalinks.

#9 @Denis-de-Bernardy
16 years ago

  • Keywords needs-patch added; has-patch removed

patch is broken again. dev feedback would be useful, too...

#10 @Denis-de-Bernardy
16 years ago

  • Component changed from Optimization to Template
  • Milestone changed from 2.8 to Future Release

moving to future, as there are a couple of related bugs on wp_list_pages being slow.

#11 @Denis-de-Bernardy
16 years ago

  • Keywords dev-feedback removed

#12 @Denis-de-Bernardy
15 years ago

  • Component changed from Template to Optimization

#13 @nacin
11 years ago

  • Component changed from Optimization to Query
  • Focuses performance added

#14 @wonderboymusic
11 years ago

  • Milestone changed from Future Release to 4.0

for 500 pages with 20 paragraphs of post_content each, it consumes 2MB for * and 300KB for ID, post_title, post_parent

Since get_pages() uses direct SQL, we can accomplish this without #19866. Officially a fan.

#15 @wonderboymusic
11 years ago

  • Milestone 4.0 deleted
  • Resolution set to maybelater
  • Status changed from reopened to closed

Actually no, scratch that. This would require a bunch of gymnastics to avoid caching the fragmented results. Not a big enough performance gain to warrant it. Would also require passing fields down to other functions like get_page_children(). I can see why no one has refreshed this patch in 5 years.

Note: See TracTickets for help on using tickets.