WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 3 months ago

#8874 reopened enhancement

wp_list_pages consume a lot of memory

Reported by: horaciod Owned by:
Milestone: Future Release 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 5 years ago.
Just found while taking a look into this ticket. wp_page_menu improvements.
8874.patch (4.8 KB) - added by hakre 5 years ago.
new argument: fields.
8874.2.patch (5.2 KB) - added by hakre 5 years ago.
Update patch to have authors describben as well. Link to codex added.
8874.3.patch (5.2 KB) - added by hakre 5 years ago.
Patch contained errors. Fixed.

Download all attachments as: .zip

Change History (17)

comment:1 follow-up: mrmist5 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.

comment:2 in reply to: ↑ 1 horaciod5 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.

comment:3 mrmist5 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

comment:4 FFEMTcJ5 years ago

  • Milestone changed from 2.8 to Future Release

comment:5 Denis-de-Bernardy5 years ago

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

dup of #8492

comment:6 Denis-de-Bernardy5 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.

hakre5 years ago

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

hakre5 years ago

new argument: fields.

comment:7 hakre5 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.

hakre5 years ago

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

hakre5 years ago

Patch contained errors. Fixed.

comment:8 Denis-de-Bernardy5 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.

comment:9 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; has-patch removed

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

comment:10 Denis-de-Bernardy5 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.

comment:11 Denis-de-Bernardy5 years ago

  • Keywords dev-feedback removed

comment:12 Denis-de-Bernardy4 years ago

  • Component changed from Template to Optimization

comment:13 nacin3 months ago

  • Component changed from Optimization to Query
  • Focuses performance added
Note: See TracTickets for help on using tickets.