[wp-trac] [WordPress Trac] #11622: switch to PDO::prepare when we require PHP 5.1

WordPress Trac wp-trac at lists.automattic.com
Wed Dec 30 14:44:03 UTC 2009


#11622: switch to PDO::prepare when we require PHP 5.1
-------------------------+--------------------------------------------------
 Reporter:  sirzooro     |       Owner:  ryan                    
     Type:  enhancement  |      Status:  new                     
 Priority:  normal       |   Milestone:  Future Release          
Component:  Database     |     Version:  2.9                     
 Severity:  normal       |    Keywords:  needs-patch dev-feedback
-------------------------+--------------------------------------------------

Comment(by Denis-de-Bernardy):

 Replying to [comment:12 josephscott]:
 > I'm curious about the suggestion that the query planner would do poorly
 with prepared statements.  Any there any references to this actually being
 the case?

 I've seen it happen in my own apps, with queries very similar to my above
 example query.

 Using PostgreSQL and with a decent amount of data, that example query ends
 up with a hash plan followed by a quick sort if you ask PG to prepare the
 statement, and with an index scan/nested loop plan if you send the final
 query instead. With large amounts of data, the difference between the two
 is significant.

 The reason the optimizer behaves like that is the same as why query
 planers don't use indexes for small amounts of data: unless you need a
 small number of rows as compared to the total number of available rows,
 it's faster to open all disc pages and weed out the needed rows (using a
 hash bucket in this particular case), than it is to loop through an index.

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


More information about the wp-trac mailing list