WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#5557 closed enhancement (fixed)

wxr importer: defer comment counts

Reported by: tellyworth Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:

Description

Comment counts are calculated and recalculated every time a comment is inserted. That's inefficient when there are multiple comments per post.

The enclosed patch implements and uses a wp_defer_comment_counting() function. It's based on wp_defer_term_counting().

I also removed the comment_exists() check in the importer, since in practice it always returns false (the post_exists() check means we only attempt to import comments when the parent post is new, and hence has no comments).

Attachments (2)

defer-comment-counts-r6528-2.patch (3.6 KB) - added by tellyworth 6 years ago.
defer-comment-counts-r6528-3.patch (3.7 KB) - added by tellyworth 6 years ago.
fix a poor assumption with comment_exists() change

Download all attachments as: .zip

Change History (5)

comment:1 lloydbudd6 years ago

  • Milestone changed from 2.5 to 2.4

tellyworth6 years ago

fix a poor assumption with comment_exists() change

comment:2 tellyworth6 years ago

Lloyd pointed out the comment_exists() change made a poor assumption. It didn't support a common use case where a second import is run after a first pass to catch up on comments that were added during the transition period. The second patch fixes this: it does the comment_exists() check when the post already exists, and skips it when it does not.

comment:3 ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [6532]) Defer comment counting. Props tellyworth. fixes #5557

Note: See TracTickets for help on using tickets.