[wp-trac] [WordPress Trac] #19007: Unnecessray database query and loop in dbDelta

WordPress Trac wp-trac at lists.automattic.com
Wed Oct 19 20:42:50 UTC 2011

#19007: Unnecessray database query and loop in dbDelta
 Reporter:  inxilpro         |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  3.2.1
 Severity:  normal           |   Keywords:  has-patch needs-testing
 The `dbDelta` function currently queries the database for all tables using
 `SHOW TABLES`, loops through that data, and then queries the database
 again to `DESCRIBE` the tables it is upgrading.  This causes some issues
 with advanced database setups where sharding is in place (not all tables
 are on the same database), but more importantly, it's completely
 unnecessary.  The function is already hitting the database for each table
 that it's comparing, so the loop can be removed, and the table's existence
 can be checked after the `DESCRIBE` query is run.  I threw together a
 quick patch, but I haven't tested it yet.  When I get a chance, I'll post
 any additional comments.

Ticket URL: <http://core.trac.wordpress.org/ticket/19007>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list