#52999 closed enhancement (invalid)
Decrease the number of SQL queries in the pages list table
| Reported by: | Chouby | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Posts, Post Types | Version: | |
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: | Focuses: | administration, performance |
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
@
6 years ago
- Keywords needs-testing added
- Milestone Awaiting Review → 5.8
- Type defect (bug) → enhancement
#3
@
6 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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
enhancementand move it for5.8consideration.