Skip to:

Opened 7 years ago

Closed 7 years ago

#3086 closed defect (bug) (duplicate)

Slow post deletion

Reported by: januzi_pl's profile januzi_pl Owned by:
Milestone: Priority: high
Severity: major Version: 2.5.12
Component: Component - Replies Keywords:


Hello again

This time I'll be complying about post deletion speed. Mysql slow query log looks like this:

# Query_time: 23.137402  Lock_time: 0.005352 Rows_sent: 1  Rows_examined: 360222 
SELECT COUNT(ID) FROM wp_posts WHERE post_parent IN ( 123194,122768,122447,121886,121814,120025,119757,
 ) AND post_status = 'publish' AND post_type = 'reply';

So, if I understand correctly, bbpress is recounting posts after each deletion, right? What's wrong with the meta data in wp_postmeta that's have something like _bbp_reply_count (or something like that)? Why is there a need to recount all of the posts?

Anyway, here's what explain says about this query:

id 	select_type 	table 	partitions 	type 	possible_keys 	key 	key_len 	ref 	rows 	filtered 	Extra 	
1 	SIMPLE 	wp_posts 	NULL	range 	type_status_date,post_parent 	post_parent 	8 	NULL	357324 	50.00 	Using index condition; Using where

I'll try adding new index into the wp_posts table, but I doubt that it will help.

How to fix problem
Use counters from wp_postmeta when possible.

Change History (1)

#1 @johnjamesjacoby
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

See #1799.

Thanks for the detailed report. You're very correct that these types of queries are not ideal.

Note: See TracTickets for help on using tickets.