#5649 closed defect (bug) (fixed)
to_ping query optimization
Reported by: | misterbisson | Owned by: | westi |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.3.2 |
Component: | Optimization | Keywords: | to_ping, mysql, query, optimization |
Focuses: | Cc: |
Description
In wp-includes/comment.php, the following query requires a full table scan and can't be improved by adding an index:
<code>$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");</code>
I can't see any obvious reasons why do_trackbacks would leave cruft in the to_ping field, and any cruft that may exist would get cleared after going through do_trackbacks again. So I'm proposing this replacement:
$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE to_ping <> AND post_status = 'publish'");
Attachments (1)
Change History (5)
#1
@
17 years ago
- Milestone changed from 2.6 to 2.5
- Owner changed from anonymous to westi
- Status changed from new to assigned
#4
@
17 years ago
For reference: Andy Skelton asking him to submit the above patch, from [wp-hackers] to_ping query optimization
Hey Casey! Your query looks great to my eyes. I would guess that the
existing code was written to avoid selecting rows full of spaces or
shorter than 'http://' (7 chars). It would be more efficient to a) use
your query, and b) make sure the field is empty when all valid pings
have been sent.
Checking through my live sites db - I have two posts with to_ping containing blank cruft.