Make WordPress Core

Opened 18 months ago

Closed 16 months ago

Last modified 10 months ago

#63014 closed enhancement (fixed)

Enhance `_wp_after_delete_font_family()` performance using the `fields` argument in `get_children()`.

Reported by: dilipbheda Owned by: flixos90
Priority: low Milestone: 6.9
Component: Query Version:
Severity: normal Keywords: has-patch
Cc: Focuses: performance

Description

The _wp_after_delete_font_family() function can be optimized by leveraging the fields argument in the get_children() function. Currently, the function retrieves unnecessary data, which affects performance.

Since we use only the ID field in the wp_delete_post() function from the get_children() object, adding the fields argument will limit the query to fetch only the required IDs, improving both performance and efficiency.

Change History (4)

This ticket was mentioned in PR #8407 on WordPress/wordpress-develop by @dilipbheda.


18 months ago
#1

#2 @flixos90
16 months ago

  • Milestone Awaiting Review6.9
  • Owner set to flixos90
  • Priority normallow
  • Status newreviewing
  • Type defect (bug)enhancement

@dilipbheda Thanks for raising this, the change makes sense to me.

I wasn't sure at first because wp_delete_post() looks up the post object anyway before deleting, so I thought looking it up in the query would be good to warm the caches.

But turns out that wp_delete_post() will always make a database request for it regardless of caches, so the extra query before to warm the caches is indeed pointless.

It's probably not going to have a notable impact on performance, but should be straightforward and low-risk enough to move forward.

Changing this to an enhancement, since it's a performance improvement, not a bug fix.

#3 @flixos90
16 months ago

  • Resolutionfixed
  • Status reviewingclosed

In 60203:

Query: Avoid unnecessary database query when deleting a font family.

Querying only the font face IDs is sufficient when deleting a font family. There is no need to warm the caches with the full objects, since wp_delete_post() will always make a direct database query to get the object anyway.

Props dilipbheda.
Fixes #63014.

This ticket was mentioned in Slack in #core by westonruter. View the logs.


10 months ago

Note: See TracTickets for help on using tickets.