Skip to:
Content

Opened 2 years ago

Closed 2 years ago

#3086 closed defect (duplicate)

Slow post deletion

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

Description

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,
119748,119009,119001,118834,118769,118649,118629,118549,118454,
118439,118402,118275,118221,117846,117376,116902,116857,116323,115879,115468,115282,115066
[...]
 ) 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
2 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.