#52999 closed enhancement (invalid)
Decrease the number of SQL queries in the pages list table
Reported by: | Chouby | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-patch needs-testing |
Focuses: | administration, performance | Cc: |
Description
In the pages list table,
WP_Posts_List_Table::_display_rows_hierarchical()
first calls get_pages()
. Then we have the following call stack:
-> WP_Posts_List_Table::single_row()
for all displayed pages
-> wp_check_post_lock()
-> get_post_meta()
The issue is that get_pages()
doesn't prime the post meta cache. Thus all calls to get_post_meta()
create a single SQL query, resulting in as many SQL queries as teh number of pages displayed in the list.
I propose to update the post cache before calling WP_Posts_List_Table::single_row()
to decrease the number of SQL queries.
Attachments (1)
Change History (8)
#2
@
3 years ago
- Keywords needs-testing added
- Milestone changed from Awaiting Review to 5.8
- Type changed from defect (bug) to enhancement
#3
@
3 years ago
I ran some quick tests using query monitor and here are the results:
Before patch: - Page Generation Time: 0,9868 | 3,3% of 30s limit - Peak Memory Usage: 87 072 kB | 16,6% of 524 288 kB limit - Database Query Time: 0,0255 - Database Queries: Total: 85 - Object Cache: 94,4% hit rate (4 506 hits, 266 misses) - - - - After patch: - Page Generation Time: 0,9690 | 3,2% of 30s limit - Peak Memory Usage: 87 065 kB | 16,6% of 524 288 kB limit - Database Query Time: 0,0217 - Database Queries: Total: 84 - Object Cache: 94,5% hit rate (4 515 hits, 264 misses)
That was tested on a small website. Would be nice to get some tests on a bigger one.
#4
@
3 years ago
- Component changed from Administration to Posts, Post Types
- Focuses administration added
Note: See
TracTickets for help on using
tickets.
Hi @Chouby,
Thanks, it looks like a great enhancement.
While I'm planning some performance tests on my side, let's change the ticket type to
enhancement
and move it for5.8
consideration.