[wp-trac] [WordPress Trac] #12257: wpdb Scales Badly Due to Unnecessary Copies of All Query Results

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 24 05:39:28 UTC 2010

#12257: wpdb Scales Badly Due to Unnecessary Copies of All Query Results
 Reporter:  miqrogroove   |       Owner:  ryan     
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  3.1      
Component:  Database      |     Version:           
 Severity:  critical      |    Keywords:  has-patch

Comment(by joelhardi):

 Incidentally, while bored last Sunday I did an additional patch that
 piggybacks on this one. It creates a results class so that the
 get_results() method of wpdb, instead of copying the result set into an
 array and returning it, instead returns an object instance that implements
 the SeekableIterator, ArrayAccess and Countable interfaces and acts as an
 interface to the MySQL result resource.

 So, it removes another layer of data copying. All the other parts of
 !WordPress manipulate it like the array they think they're getting.

 The final result of this experiment was that it was 5-10% slower and used
 about that much more memory. So, not practical for actual use, but good to
 know that !WordPress isn't needlessly retrieving arrays of unused data.

 The one thing it might actually be useful for is debugging or profiling --
 i.e. I have a debug version that subclasses and echos/logs debug
 information when various things happen, like when these "arrays" are read
 from or written to. But, then again, you can use a real debugger for that.

Ticket URL: <http://core.trac.wordpress.org/ticket/12257#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list