[wp-trac] [WordPress Trac] #15158: wpdb insert & update with null values

WordPress Trac noreply at wordpress.org
Tue Jan 8 09:26:43 UTC 2013


#15158: wpdb insert & update with null values
-------------------------+-----------------------------
 Reporter:  westi        |       Owner:  sorich87
     Type:  enhancement  |      Status:  accepted
 Priority:  normal       |   Milestone:  Future Release
Component:  Database     |     Version:  3.0.1
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+-----------------------------

Comment (by jbutkus):

 Replying to [comment:34 miqrogroove]:
 > I think a better strategy would be to run two separate loops:
 foreach($args) to create a list of which args were NULL and unset them,
 followed by foreach($positions[0]) to modify the query string.
 >
 > This strategy would avoid duplicating the $args array, which is
 potentially extremely expensive when working with large queries.

 Why I propose {{{array_values}}} is that it is faster than {{{foreach}}}
 by some 65% (several timings running plain {{{foreach}}} with value-copy,
 vs. {{{array_values}}}, on 10.000 elements array). Thus having two
 {{{foreach}}} loops shall not give viable performance impact. And we get
 rid of unnecessary keys.

 I have uploaded a [attachment:wpdb_prepare_null.15158.v4.patch​ new
 patch], which may be treated as more memory-concious. Here I got rid of
 extra {{{$values}}} variable.

 What do you think of this approach?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15158#comment:35>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list