WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#6770 closed defect (bug) (fixed)

large number of queries in the pages management page

Reported by: Denis-de-Bernardy Owned by:
Milestone: 2.6 Priority: normal
Severity: minor Version: 2.5
Component: Optimization Keywords:
Focuses: Cc:

Description

On a site with lots of static pages, you get all sorts of queries like:

array(3) {
    [0]=>
    string(87) "SELECT COUNT(*) FROM wp_comments WHERE comment_post_ID = 553 AND comment_approved = '0'"
    [1]=>
    float(0.00033998489379883)
    [2]=>
    string(24) "get_pending_comments_num"

they could be replaced by a single query, such as:

SELECT comment_post_ID, COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = IN ( post ID list ) AND comment_approved = '0' GROUP BY comment_post_ID

Attachments (1)

get_comments_pending_num.diff (2.1 KB) - added by ryan 6 years ago.
Consolidate get_pending_comments_num() queries

Download all attachments as: .zip

Change History (7)

comment:1 Denis-de-Bernardy6 years ago

also, on the same page, this query gets run twice:

[13]=>
  array(3) {
    [0]=>
    string(103) "SELECT post_status, COUNT( * ) AS num_posts FROM wp_posts WHERE post_type = 'page' GROUP BY post_status"
    [1]=>
    float(0.0020089149475098)
    [2]=>
    string(14) "wp_count_posts"
  }
  [14]=>
  array(3) {
    [0]=>
    string(103) "SELECT post_status, COUNT( * ) AS num_posts FROM wp_posts WHERE post_type = 'page' GROUP BY post_status"
    [1]=>
    float(0.0018351078033447)
    [2]=>
    string(14) "wp_count_posts"
  }

D.

comment:2 ryan6 years ago

[7637] eliminates extra post_status count queries. Working on the post comment count queries.

ryan6 years ago

Consolidate get_pending_comments_num() queries

comment:3 ryan6 years ago

(In [7775]) Consolidate get_pending_comments_num() queries. see #6770

comment:4 ryan6 years ago

(In [7776]) Consolidate get_pending_comments_num() queries. see #6770 for 2.5

comment:5 DD326 years ago

  • Milestone set to 2.6

comment:6 ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.