[wp-trac] [WordPress Trac] #48408: Introduce eagerloading of meta data

WordPress Trac noreply at wordpress.org
Wed Oct 23 13:49:00 UTC 2019


#48408: Introduce eagerloading of meta data
-------------------------------------------+-----------------------------
 Reporter:  mattiasf                       |      Owner:  (none)
     Type:  enhancement                    |     Status:  new
 Priority:  normal                         |  Milestone:  Awaiting Review
Component:  Query                          |    Version:
 Severity:  major                          |   Keywords:
  Focuses:  performance, coding-standards  |
-------------------------------------------+-----------------------------
 I believe it should be possible to introduce eagerloading to
 postmeta/attachments.

 In "Laravel" language you would do:

 <?php

 $posts = Post::with('meta')->take(10)->get();
 ?>

 Which would produce two queries: 1) for the posts table 2) for the
 post_meta table where post ids IN posts result.

 That would produce TWO queries to fetch 10 posts and ALL of its meta data,
 instead of currently where it produces a lot of requests to the database.

 A SO user produced a draft that illustrates how it could work, see:
 https://wordpress.stackexchange.com/a/225743/50042

 Speed is alfaomega in these times, and I think WordPress should take it
 way more serious.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48408>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list