Opened 4 years ago
Last modified 3 years ago
#8874 reopened enhancement
wp_list_pages consume a lot of memory
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Optimization | Version: | 2.7 |
| Severity: | normal | Keywords: | needs-patch |
| 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)
Change History (16)
comment:2
in reply to:
↑ 1
horaciod
— 4 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
mrmist
— 4 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:5
Denis-de-Bernardy
— 4 years ago
- Milestone Future Release deleted
- Resolution set to duplicate
- Status changed from new to closed
dup of #8492
comment:6
Denis-de-Bernardy
— 4 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.
comment:7
hakre
— 4 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.
comment:8
Denis-de-Bernardy
— 4 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-Bernardy
— 4 years ago
- Keywords needs-patch added; has-patch removed
patch is broken again. dev feedback would be useful, too...
comment:10
Denis-de-Bernardy
— 4 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-Bernardy
— 4 years ago
- Keywords dev-feedback removed
comment:12
Denis-de-Bernardy
— 3 years ago
- Component changed from Template to Optimization
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.